﻿#include "GameScene.h"
#include "../MirGraphics/DXManager.h"
#include "../Forms/Client.CMain.h"
#include "../Settings.h"
#include "../KeyBindSettings.h"
#include "../MirNetwork/Network.h"
#include "../../Shared/ClientPackets.h"
#include "../../Shared/Language.h"
#include "../MirGraphics/MLibrary.h"
#include "../MirSounds/SoundManager.h"
#include "../MirControls/MirMessageBox.h"
#include "../../Shared/Functions/Functions.h"
#include "../MirObjects/PlayerObject.h"
#include "../../Shared/Functions/RegexFunctions.h"
#include "SelectScene.h"
#include "../MirObjects/ItemObject.h"
#include "../MirObjects/MonsterObject.h"
#include "../../Shared/Globals.h"
#include "../MirObjects/Damage.h"
#include "../../Shared/Data/Stat.h"
#include "../MirObjects/NPCObject.h"
#include "../MirControls/MirInputBox.h"
#include "../MirObjects/SpellObject.h"
#include "../MirObjects/DecoObject.h"
#include "../Utils/BrowserHelper.h"
#include "../MirControls/MirAmountBox.h"

using namespace Client::MirControls;
using namespace Client::MirGraphics;
using namespace Client::MirNetwork;
using namespace Client::MirObjects;
using namespace Client::MirSounds;
using namespace SlimDX;
using namespace SlimDX::Direct3D9;
namespace S = ServerPackets;
namespace C = ClientPackets;
using Effect = Client::MirObjects::Effect;
using namespace Client::MirScenes::Dialogs;
using namespace Client::Utils;

namespace Client::MirScenes
{

GameScene *GameScene::Scene;

    UserObject *GameScene::getUser()
    {
        return MapObject::User;
    }

    void GameScene::setUser(UserObject *value)
    {
        MapObject::User = value;
    }

long long GameScene::MoveTime = 0;
long long GameScene::AttackTime = 0;
long long GameScene::NextRunTime = 0;
long long GameScene::LogTime = 0;
long long GameScene::LastRunTime = 0;
bool GameScene::CanMove = false;
bool GameScene::CanRun = false;
std::vector<ItemInfo*> GameScene::ItemInfoList;
std::vector<UserId*> GameScene::UserIdList;
std::vector<UserItem*> GameScene::ChatItemList;
std::vector<ClientQuestInfo*> GameScene::QuestInfoList;
std::vector<GameShopItem*> GameScene::GameShopInfoList;
std::vector<ClientRecipeInfo*> GameScene::RecipeInfoList;
std::vector<UserItem*> GameScene::Storage(80);
std::vector<UserItem*> GameScene::GuildStorage(112);
std::vector<UserItem*> GameScene::Refine(16);
UserItem *GameScene::HoverItem;
UserItem *GameScene::SelectedItem;
MirItemCell *GameScene::SelectedCell;
bool GameScene::PickedUpGold = false;
long long GameScene::UseItemTime = 0;
long long GameScene::PickUpTime = 0;
long long GameScene::DropViewTime = 0;
long long GameScene::TargetDeadTime = 0;
unsigned int GameScene::Gold = 0;
unsigned int GameScene::Credit = 0;
long long GameScene::InspectTime = 0;
long long GameScene::NPCTime = 0;
unsigned int GameScene::NPCID = 0;
float GameScene::NPCRate = 0;
unsigned int GameScene::DefaultNPCID = 0;
bool GameScene::HideAddedStoreStats = false;
bool GameScene::Slaying = false;
bool GameScene::Thrusting = false;
bool GameScene::HalfMoon = false;
bool GameScene::CrossHalfMoon = false;
bool GameScene::DoubleSlash = false;
bool GameScene::TwinDrakeBlade = false;
bool GameScene::FlamingSword = false;
long long GameScene::SpellTime = 0;

    GameScene::GameScene()
    {
        MapControl->setAutoRun(false);
        MapControl::AutoHit = false;
        Slaying = false;
        Thrusting = false;
        HalfMoon = false;
        CrossHalfMoon = false;
        DoubleSlash = false;
        TwinDrakeBlade = false;
        FlamingSword = false;

        Scene = this;
        setBackColour(Color::Transparent);
        MoveTime = CMain::Time;

        KeyDown += GameScene_KeyDown;

        MainDialog = new MainDialog();
        MainDialog->setParent(this);
        ChatDialog = new ChatDialog();
        ChatDialog->setParent(this);
        ChatControl = new ChatControlBar();
        ChatControl->setParent(this);
        InventoryDialog = new InventoryDialog();
        InventoryDialog->setParent(this);
        CharacterDialog = new CharacterDialog();
        CharacterDialog->setParent(this);
        CharacterDialog->setVisible(false);
        BeltDialog = new BeltDialog();
        BeltDialog->setParent(this);
        StorageDialog = new StorageDialog();
        StorageDialog->setParent(this);
        StorageDialog->setVisible(false);
        CraftDialog = new CraftDialog();
        CraftDialog->setParent(this);
        CraftDialog->setVisible(false);
        MiniMapDialog = new MiniMapDialog();
        MiniMapDialog->setParent(this);
        InspectDialog = new InspectDialog();
        InspectDialog->setParent(this);
        InspectDialog->setVisible(false);
        OptionDialog = new OptionDialog();
        OptionDialog->setParent(this);
        OptionDialog->setVisible(false);
        MenuDialog = new MenuDialog();
        MenuDialog->setParent(this);
        MenuDialog->setVisible(false);
        NPCDialog = new NPCDialog();
        NPCDialog->setParent(this);
        NPCDialog->setVisible(false);
        NPCGoodsDialog = new NPCGoodsDialog(PanelType::Buy);
        NPCGoodsDialog->setParent(this);
        NPCGoodsDialog->setVisible(false);
        NPCSubGoodsDialog = new NPCGoodsDialog(PanelType::BuySub);
        NPCSubGoodsDialog->setParent(this);
        NPCSubGoodsDialog->setVisible(false);
        NPCCraftGoodsDialog = new NPCGoodsDialog(PanelType::Craft);
        NPCCraftGoodsDialog->setParent(this);
        NPCCraftGoodsDialog->setVisible(false);
        NPCDropDialog = new NPCDropDialog();
        NPCDropDialog->setParent(this);
        NPCDropDialog->setVisible(false);
        NPCAwakeDialog = new NPCAwakeDialog();
        NPCAwakeDialog->setParent(this);
        NPCAwakeDialog->setVisible(false);

        HelpDialog = new HelpDialog();
        HelpDialog->setParent(this);
        HelpDialog->setVisible(false);
        KeyboardLayoutDialog = new KeyboardLayoutDialog();
        KeyboardLayoutDialog->setParent(this);
        KeyboardLayoutDialog->setVisible(false);
        NoticeDialog = new NoticeDialog();
        NoticeDialog->setParent(this);
        NoticeDialog->setVisible(false);

        MountDialog = new MountDialog();
        MountDialog->setParent(this);
        MountDialog->setVisible(false);
        FishingDialog = new FishingDialog();
        FishingDialog->setParent(this);
        FishingDialog->setVisible(false);
        FishingStatusDialog = new FishingStatusDialog();
        FishingStatusDialog->setParent(this);
        FishingStatusDialog->setVisible(false);

        GroupDialog = new GroupDialog();
        GroupDialog->setParent(this);
        GroupDialog->setVisible(false);
        GuildDialog = new GuildDialog();
        GuildDialog->setParent(this);
        GuildDialog->setVisible(false);

        BigMapDialog = new BigMapDialog();
        BigMapDialog->setParent(this);
        BigMapDialog->setVisible(false);
        TrustMerchantDialog = new TrustMerchantDialog();
        TrustMerchantDialog->setParent(this);
        TrustMerchantDialog->setVisible(false);
        CharacterDuraPanel = new CharacterDuraPanel();
        CharacterDuraPanel->setParent(this);
        CharacterDuraPanel->setVisible(false);
        DuraStatusPanel = new DuraStatusDialog();
        DuraStatusPanel->setParent(this);
        DuraStatusPanel->setVisible(true);
        TradeDialog = new TradeDialog();
        TradeDialog->setParent(this);
        TradeDialog->setVisible(false);
        GuestTradeDialog = new GuestTradeDialog();
        GuestTradeDialog->setParent(this);
        GuestTradeDialog->setVisible(false);

        CustomPanel1 = new CustomPanel1(this);
        CustomPanel1->setVisible(false);
        SocketDialog = new SocketDialog();
        SocketDialog->setParent(this);
        SocketDialog->setVisible(false);

        SkillBarDialog *Bar1 = new SkillBarDialog();
        Bar1->setParent(this);
        Bar1->setVisible(false);
        Bar1->BarIndex = 0;
        SkillBarDialogs.push_back(Bar1);
        SkillBarDialog *Bar2 = new SkillBarDialog();
        Bar2->setParent(this);
        Bar2->setVisible(false);
        Bar2->BarIndex = 1;
        SkillBarDialogs.push_back(Bar2);
        ChatOptionDialog = new ChatOptionDialog();
        ChatOptionDialog->setParent(this);
        ChatOptionDialog->setVisible(false);
        ChatNoticeDialog = new ChatNoticeDialog();
        ChatNoticeDialog->setParent(this);
        ChatNoticeDialog->setVisible(false);

        QuestListDialog = new QuestListDialog();
        QuestListDialog->setParent(this);
        QuestListDialog->setVisible(false);
        QuestDetailDialog = new QuestDetailDialog();
        QuestDetailDialog->setParent(this);
        QuestDetailDialog->setVisible(false);
        QuestTrackingDialog = new QuestTrackingDialog();
        QuestTrackingDialog->setParent(this);
        QuestTrackingDialog->setVisible(false);
        QuestLogDialog = new QuestDiaryDialog();
        QuestLogDialog->setParent(this);
        QuestLogDialog->setVisible(false);

        RankingDialog = new RankingDialog();
        RankingDialog->setParent(this);
        RankingDialog->setVisible(false);

        MailListDialog = new MailListDialog();
        MailListDialog->setParent(this);
        MailListDialog->setVisible(false);
        MailComposeLetterDialog = new MailComposeLetterDialog();
        MailComposeLetterDialog->setParent(this);
        MailComposeLetterDialog->setVisible(false);
        MailComposeParcelDialog = new MailComposeParcelDialog();
        MailComposeParcelDialog->setParent(this);
        MailComposeParcelDialog->setVisible(false);
        MailReadLetterDialog = new MailReadLetterDialog();
        MailReadLetterDialog->setParent(this);
        MailReadLetterDialog->setVisible(false);
        MailReadParcelDialog = new MailReadParcelDialog();
        MailReadParcelDialog->setParent(this);
        MailReadParcelDialog->setVisible(false);

        IntelligentCreatureDialog = new IntelligentCreatureDialog();
        IntelligentCreatureDialog->setParent(this);
        IntelligentCreatureDialog->setVisible(false);
        IntelligentCreatureOptionsDialog = new IntelligentCreatureOptionsDialog();
        IntelligentCreatureOptionsDialog->setParent(this);
        IntelligentCreatureOptionsDialog->setVisible(false);
        IntelligentCreatureOptionsGradeDialog = new IntelligentCreatureOptionsGradeDialog();
        IntelligentCreatureOptionsGradeDialog->setParent(this);
        IntelligentCreatureOptionsGradeDialog->setVisible(false);

        RefineDialog = new RefineDialog();
        RefineDialog->setParent(this);
        RefineDialog->setVisible(false);
        RelationshipDialog = new RelationshipDialog();
        RelationshipDialog->setParent(this);
        RelationshipDialog->setVisible(false);
        FriendDialog = new FriendDialog();
        FriendDialog->setParent(this);
        FriendDialog->setVisible(false);
        MemoDialog = new MemoDialog();
        MemoDialog->setParent(this);
        MemoDialog->setVisible(false);
        MentorDialog = new MentorDialog();
        MentorDialog->setParent(this);
        MentorDialog->setVisible(false);
        GameShopDialog = new GameShopDialog();
        GameShopDialog->setParent(this);
        GameShopDialog->setVisible(false);
        ReportDialog = new ReportDialog();
        ReportDialog->setParent(this);
        ReportDialog->setVisible(false);

        ItemRentingDialog = new ItemRentingDialog();
        ItemRentingDialog->setParent(this);
        ItemRentingDialog->setVisible(false);
        ItemRentDialog = new ItemRentDialog();
        ItemRentDialog->setParent(this);
        ItemRentDialog->setVisible(false);
        GuestItemRentingDialog = new GuestItemRentingDialog();
        GuestItemRentingDialog->setParent(this);
        GuestItemRentingDialog->setVisible(false);
        GuestItemRentDialog = new GuestItemRentDialog();
        GuestItemRentDialog->setParent(this);
        GuestItemRentDialog->setVisible(false);
        ItemRentalDialog = new ItemRentalDialog();
        ItemRentalDialog->setParent(this);
        ItemRentalDialog->setVisible(false);

        BuffsDialog = new BuffDialog();
        BuffsDialog->setParent(this);
        BuffsDialog->setVisible(true);
        KeyboardLayoutDialog = new KeyboardLayoutDialog();
        KeyboardLayoutDialog->setParent(this);
        KeyboardLayoutDialog->setVisible(false);

        TimerControl = new TimerDialog();
        TimerControl->setParent(this);
        TimerControl->setVisible(false);
        CompassControl = new CompassDialog();
        CompassControl->setParent(this);
        CompassControl->setVisible(false);

        for (int i = 0; i < OutputLines.size(); i++)
        {
            MirLabel *tempVar = new MirLabel();
            tempVar->setAutoSize(true);
            tempVar->setBackColour(Color::Transparent);
            System::Drawing::Font tempVar2(Settings::FontName, 10.0F);
            tempVar->setFont(&tempVar2);
            tempVar->setForeColour(Color::LimeGreen);
            Point tempVar3(20, 25 + i * 13);
            tempVar->setLocation(&tempVar3);
            tempVar->setOutLine(true);
            OutputLines[i] = tempVar;

            delete tempVar;
        }

//C# TO C++ CONVERTER TODO TASK: A 'delete Bar2' statement was not added since Bar2 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete Bar1' statement was not added since Bar1 was passed to a method or constructor. Handle memory management manually.
    }

    void GameScene::UpdateMouseCursor()
    {
        if (!Settings::UseMouseCursors)
        {
            return;
        }

        if (GameScene::HoverItem != nullptr)
        {
            if (GameScene::SelectedCell != nullptr && GameScene::SelectedCell->getItem() != nullptr && GameScene::SelectedCell->getItem()->Info->Type == ItemType::Gem && CMain::Ctrl)
            {
                CMain::SetMouseCursor(MouseCursor::Upgrade);
            }
            else
            {
                CMain::SetMouseCursor(MouseCursor::Default);
            }
        }
        else if (MapObject::MouseObject != nullptr)
        {
            switch (MapObject::MouseObject->getRace())
            {
                case ObjectType::Monster:
                    CMain::SetMouseCursor(MouseCursor::Attack);
                    break;
                case ObjectType::Merchant:
                    CMain::SetMouseCursor(MouseCursor::NPCTalk);
                    break;
                case ObjectType::Player:
                    if (CMain::Shift)
                    {
                        CMain::SetMouseCursor(MouseCursor::AttackRed);
                    }
                    else
                    {
                        CMain::SetMouseCursor(MouseCursor::Default);
                    }
                    break;
                default:
                    CMain::SetMouseCursor(MouseCursor::Default);
                    break;
            }
        }
        else
        {
            CMain::SetMouseCursor(MouseCursor::Default);
        }

    }

    void GameScene::OutputMessage(const std::string &message, OutputMessageType type)
    {
        OutPutMessage *tempVar = new OutPutMessage();
        tempVar->Message = message;
        tempVar->ExpireTime = CMain::Time + 5000;
        tempVar->Type = type;
        OutputMessages.push_back(tempVar);
        if (OutputMessages.size() > 10)
        {
            OutputMessages.erase(OutputMessages.begin());
        }

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
    }

    void GameScene::ProcessOuput()
    {
        for (int i = 0; i < OutputMessages.size(); i++)
        {
            if (CMain::Time >= OutputMessages[i]->ExpireTime)
            {
                OutputMessages.erase(OutputMessages.begin() + i);
            }
        }

        for (int i = 0; i < OutputLines.size(); i++)
        {
            if (OutputMessages.size() > i)
            {
                Color *color;
                switch (OutputMessages[i]->Type)
                {
                    case OutputMessageType::Quest:
                        color = Color::Gold;
                        break;
                    case OutputMessageType::Guild:
                        color = Color::DeepPink;
                        break;
                    default:
                        color = Color::LimeGreen;
                        break;
                }

                OutputLines[i]->setText(OutputMessages[i]->Message);
                OutputLines[i]->setForeColour(color);
                OutputLines[i]->setVisible(true);
            }
            else
            {
                OutputLines[i]->setText("");
                OutputLines[i]->setVisible(false);
            }
        }
    }

    void GameScene::GameScene_KeyDown(std::any sender, KeyEventArgs *e)
    {
        if (GameScene::Scene->KeyboardLayoutDialog->WaitingForBind != nullptr)
        {
            GameScene::Scene->KeyboardLayoutDialog->CheckNewInput(e);
            return;
        }

        for (auto KeyCheck : CMain::InputKeys->Keylist)
        {
            if (KeyCheck->Key == Keys->None)
            {
                continue;
            }
            if (KeyCheck->Key != e->KeyCode)
            {
                continue;
            }
            if ((KeyCheck->RequireAlt != 2) && (KeyCheck->RequireAlt != (CMain::Alt ? 1 : 0)))
            {
                continue;
            }
            if ((KeyCheck->RequireShift != 2) && (KeyCheck->RequireShift != (CMain::Shift ? 1 : 0)))
            {
                continue;
            }
            if ((KeyCheck->RequireCtrl != 2) && (KeyCheck->RequireCtrl != (CMain::Ctrl ? 1 : 0)))
            {
                continue;
            }
            if ((KeyCheck->RequireTilde != 2) && (KeyCheck->RequireTilde != (CMain::Tilde ? 1 : 0)))
            {
                continue;
            }
            //now run the real code
            switch (KeyCheck->function)
            {
                case KeybindOptions::Bar1Skill1:
                    UseSpell(1);
                    break;
                case KeybindOptions::Bar1Skill2:
                    UseSpell(2);
                    break;
                case KeybindOptions::Bar1Skill3:
                    UseSpell(3);
                    break;
                case KeybindOptions::Bar1Skill4:
                    UseSpell(4);
                    break;
                case KeybindOptions::Bar1Skill5:
                    UseSpell(5);
                    break;
                case KeybindOptions::Bar1Skill6:
                    UseSpell(6);
                    break;
                case KeybindOptions::Bar1Skill7:
                    UseSpell(7);
                    break;
                case KeybindOptions::Bar1Skill8:
                    UseSpell(8);
                    break;
                case KeybindOptions::Bar2Skill1:
                    UseSpell(9);
                    break;
                case KeybindOptions::Bar2Skill2:
                    UseSpell(10);
                    break;
                case KeybindOptions::Bar2Skill3:
                    UseSpell(11);
                    break;
                case KeybindOptions::Bar2Skill4:
                    UseSpell(12);
                    break;
                case KeybindOptions::Bar2Skill5:
                    UseSpell(13);
                    break;
                case KeybindOptions::Bar2Skill6:
                    UseSpell(14);
                    break;
                case KeybindOptions::Bar2Skill7:
                    UseSpell(15);
                    break;
                case KeybindOptions::Bar2Skill8:
                    UseSpell(16);
                    break;
                case KeybindOptions::Inventory:
                case KeybindOptions::Inventory2:
                    if (!InventoryDialog->getVisible())
                    {
                        InventoryDialog->Show();
                    }
                    else
                    {
                        InventoryDialog->Hide();
                    }
                    break;
                case KeybindOptions::Equipment:
                case KeybindOptions::Equipment2:
                    if (!CharacterDialog->getVisible() || !CharacterDialog->CharacterPage->getVisible())
                    {
                        CharacterDialog->Show();
                        CharacterDialog->ShowCharacterPage();
                    }
                    else
                    {
                        CharacterDialog->Hide();
                    }
                    break;
                case KeybindOptions::Skills:
                case KeybindOptions::Skills2:
                    if (!CharacterDialog->getVisible() || !CharacterDialog->SkillPage->getVisible())
                    {
                        CharacterDialog->Show();
                        CharacterDialog->ShowSkillPage();
                    }
                    else
                    {
                        CharacterDialog->Hide();
                    }
                    break;
                case KeybindOptions::Creature:
                    if (!IntelligentCreatureDialog->getVisible())
                    {
                        IntelligentCreatureDialog->Show();
                    }
                    else
                    {
                        IntelligentCreatureDialog->Hide();
                    }
                    break;
                case KeybindOptions::MountWindow:
                    if (!MountDialog->getVisible())
                    {
                        MountDialog->Show();
                    }
                    else
                    {
                        MountDialog->Hide();
                    }
                    break;

                case KeybindOptions::GameShop:
                    if (!GameShopDialog->getVisible())
                    {
                        GameShopDialog->Show();
                    }
                    else
                    {
                        GameShopDialog->Hide();
                    }
                    break;
                case KeybindOptions::Fishing:
                    if (!FishingDialog->getVisible())
                    {
                        FishingDialog->Show();
                    }
                    else
                    {
                        FishingDialog->Hide();
                    }
                    break;
                case KeybindOptions::Skillbar:
                    if (!Settings::SkillBar)
                    {
                        for (auto Bar : SkillBarDialogs)
                        {
                            Bar->Show();
                        }
                    }
                    else
                    {
                        for (auto Bar : SkillBarDialogs)
                        {
                            Bar->Hide();
                        }
                    }
                    break;
                case KeybindOptions::Mount:
                    if (GameScene::Scene->MountDialog->CanRide())
                    {
                        GameScene::Scene->MountDialog->Ride();
                    }
                    break;
                case KeybindOptions::Mentor:
                    if (!MentorDialog->getVisible())
                    {
                        MentorDialog->Show();
                    }
                    else
                    {
                        MentorDialog->Hide();
                    }
                    break;
                case KeybindOptions::Relationship:
                    if (!RelationshipDialog->getVisible())
                    {
                        RelationshipDialog->Show();
                    }
                    else
                    {
                        RelationshipDialog->Hide();
                    }
                    break;
                case KeybindOptions::Friends:
                    if (!FriendDialog->getVisible())
                    {
                        FriendDialog->Show();
                    }
                    else
                    {
                        FriendDialog->Hide();
                    }
                    break;
                case KeybindOptions::Guilds:
                    if (!GuildDialog->getVisible())
                    {
                        GuildDialog->Show();
                    }
                    else
                    {
                        GuildDialog->Hide();
                    }
                    break;

                case KeybindOptions::Ranking:
                    if (!RankingDialog->getVisible())
                    {
                        RankingDialog->Show();
                    }
                    else
                    {
                        RankingDialog->Hide();
                    }
                    break;
                case KeybindOptions::Quests:
                    if (!QuestLogDialog->getVisible())
                    {
                        QuestLogDialog->Show();
                    }
                    else
                    {
                        QuestLogDialog->Hide();
                    }
                    break;
                case KeybindOptions::Exit:
                    QuitGame();
                    return;

                case KeybindOptions::Closeall:
                    InventoryDialog->Hide();
                    CharacterDialog->Hide();
                    OptionDialog->Hide();
                    MenuDialog->Hide();
                    if (NPCDialog->getVisible())
                    {
                        NPCDialog->Hide();
                    }
                    HelpDialog->Hide();
                    KeyboardLayoutDialog->Hide();
                    RankingDialog->Hide();
                    IntelligentCreatureDialog->Hide();
                    IntelligentCreatureOptionsDialog->Hide();
                    IntelligentCreatureOptionsGradeDialog->Hide();
                    MountDialog->Hide();
                    FishingDialog->Hide();
                    FriendDialog->Hide();
                    RelationshipDialog->Hide();
                    MentorDialog->Hide();
                    GameShopDialog->Hide();
                    GroupDialog->Hide();
                    GuildDialog->Hide();
                    InspectDialog->Hide();
                    StorageDialog->Hide();
                    TrustMerchantDialog->Hide();
                    //CharacterDuraPanel.Hide();
                    QuestListDialog->Hide();
                    QuestDetailDialog->Hide();
                    QuestLogDialog->Hide();
                    NPCAwakeDialog->Hide();
                    RefineDialog->Hide();
                    BigMapDialog->Hide();
                    if (FishingStatusDialog->bEscExit)
                    {
                        FishingStatusDialog->Cancel();
                    }
                    MailComposeLetterDialog->Hide();
                    MailComposeParcelDialog->Hide();
                    MailListDialog->Hide();
                    MailReadLetterDialog->Hide();
                    MailReadParcelDialog->Hide();
                    ItemRentalDialog->Hide();
                    NoticeDialog->Hide();



                    GameScene::Scene->DisposeItemLabel();
                    break;
                case KeybindOptions::Options:
                case KeybindOptions::Options2:
                    if (!OptionDialog->getVisible())
                    {
                        OptionDialog->Show();
                    }
                    else
                    {
                        OptionDialog->Hide();
                    }
                    break;
                case KeybindOptions::Group:
                    if (!GroupDialog->getVisible())
                    {
                        GroupDialog->Show();
                    }
                    else
                    {
                        GroupDialog->Hide();
                    }
                    break;
                case KeybindOptions::Belt:
                    if (!BeltDialog->getVisible())
                    {
                        BeltDialog->Show();
                    }
                    else
                    {
                        BeltDialog->Hide();
                    }
                    break;
                case KeybindOptions::BeltFlip:
                    BeltDialog->Flip();
                    break;
                case KeybindOptions::Pickup:
                    if (CMain::Time > PickUpTime)
                    {
                        PickUpTime = CMain::Time + 200;
                        C::PickUp tempVar();
                        Network::Enqueue(&tempVar);
                    }
                    break;
                case KeybindOptions::Belt1:
                case KeybindOptions::Belt1Alt:
                    BeltDialog->Grid[0]->UseItem();
                    break;
                case KeybindOptions::Belt2:
                case KeybindOptions::Belt2Alt:
                    BeltDialog->Grid[1]->UseItem();
                    break;
                case KeybindOptions::Belt3:
                case KeybindOptions::Belt3Alt:
                    BeltDialog->Grid[2]->UseItem();
                    break;
                case KeybindOptions::Belt4:
                case KeybindOptions::Belt4Alt:
                    BeltDialog->Grid[3]->UseItem();
                    break;
                case KeybindOptions::Belt5:
                case KeybindOptions::Belt5Alt:
                    BeltDialog->Grid[4]->UseItem();
                    break;
                case KeybindOptions::Belt6:
                case KeybindOptions::Belt6Alt:
                    BeltDialog->Grid[5]->UseItem();
                    break;
                case KeybindOptions::Logout:
                    LogOut();
                    break;
                case KeybindOptions::Minimap:
                    MiniMapDialog->Toggle();
                    break;
                case KeybindOptions::Bigmap:
                    BigMapDialog->Toggle();
                    break;
                case KeybindOptions::Trade:
                    C::TradeRequest tempVar2();
                    Network::Enqueue(&tempVar2);
                    break;
                case KeybindOptions::Rental:
                    ItemRentalDialog->Toggle();
                    break;
                case KeybindOptions::ChangePetmode:
                    ChangePetMode();
                    break;
                case KeybindOptions::PetmodeBoth:
                    C::ChangePMode *tempVar3 = new C::ChangePMode();
                    tempVar3->Mode = PetMode::Both;
                    Network::Enqueue(tempVar3);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                    return;
                case KeybindOptions::PetmodeMoveonly:
                    C::ChangePMode *tempVar4 = new C::ChangePMode();
                    tempVar4->Mode = PetMode::MoveOnly;
                    Network::Enqueue(tempVar4);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar4' statement was not added since tempVar4 was passed to a method or constructor. Handle memory management manually.
                    return;
                case KeybindOptions::PetmodeAttackonly:
                    C::ChangePMode *tempVar5 = new C::ChangePMode();
                    tempVar5->Mode = PetMode::AttackOnly;
                    Network::Enqueue(tempVar5);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar5' statement was not added since tempVar5 was passed to a method or constructor. Handle memory management manually.
                    return;
                case KeybindOptions::PetmodeNone:
                    C::ChangePMode *tempVar6 = new C::ChangePMode();
                    tempVar6->Mode = PetMode::None;
                    Network::Enqueue(tempVar6);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar6' statement was not added since tempVar6 was passed to a method or constructor. Handle memory management manually.
                    return;
                case KeybindOptions::CreatureAutoPickup: //semiauto!
                    C::IntelligentCreaturePickup *tempVar7 = new C::IntelligentCreaturePickup();
                    tempVar7->MouseMode = false;
                    tempVar7->Location = MapControl::getMapLocation();
                    Network::Enqueue(tempVar7);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar7' statement was not added since tempVar7 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar6' statement was not added since tempVar6 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar5' statement was not added since tempVar5 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar4' statement was not added since tempVar4 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                    break;
                case KeybindOptions::CreaturePickup:
                    C::IntelligentCreaturePickup *tempVar8 = new C::IntelligentCreaturePickup();
                    tempVar8->MouseMode = true;
                    tempVar8->Location = MapControl::getMapLocation();
                    Network::Enqueue(tempVar8);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar8' statement was not added since tempVar8 was passed to a method or constructor. Handle memory management manually.
                    break;
                case KeybindOptions::ChangeAttackmode:
                    ChangeAttackMode();
                    break;
                case KeybindOptions::AttackmodePeace:
                    C::ChangeAMode *tempVar9 = new C::ChangeAMode();
                    tempVar9->Mode = AttackMode::Peace;
                    Network::Enqueue(tempVar9);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar9' statement was not added since tempVar9 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar8' statement was not added since tempVar8 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar7' statement was not added since tempVar7 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar6' statement was not added since tempVar6 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar5' statement was not added since tempVar5 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar4' statement was not added since tempVar4 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                    return;
                case KeybindOptions::AttackmodeGroup:
                    C::ChangeAMode *tempVar10 = new C::ChangeAMode();
                    tempVar10->Mode = AttackMode::Group;
                    Network::Enqueue(tempVar10);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar10' statement was not added since tempVar10 was passed to a method or constructor. Handle memory management manually.
                    return;
                case KeybindOptions::AttackmodeGuild:
                    C::ChangeAMode *tempVar11 = new C::ChangeAMode();
                    tempVar11->Mode = AttackMode::Guild;
                    Network::Enqueue(tempVar11);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar11' statement was not added since tempVar11 was passed to a method or constructor. Handle memory management manually.
                    return;
                case KeybindOptions::AttackmodeEnemyguild:
                    C::ChangeAMode *tempVar12 = new C::ChangeAMode();
                    tempVar12->Mode = AttackMode::EnemyGuild;
                    Network::Enqueue(tempVar12);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar12' statement was not added since tempVar12 was passed to a method or constructor. Handle memory management manually.
                    return;
                case KeybindOptions::AttackmodeRedbrown:
                    C::ChangeAMode *tempVar13 = new C::ChangeAMode();
                    tempVar13->Mode = AttackMode::RedBrown;
                    Network::Enqueue(tempVar13);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar13' statement was not added since tempVar13 was passed to a method or constructor. Handle memory management manually.
                    return;
                case KeybindOptions::AttackmodeAll:
                    C::ChangeAMode *tempVar14 = new C::ChangeAMode();
                    tempVar14->Mode = AttackMode::All;
                    Network::Enqueue(tempVar14);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar14' statement was not added since tempVar14 was passed to a method or constructor. Handle memory management manually.
                    return;

                case KeybindOptions::Help:
                    if (!HelpDialog->getVisible())
                    {
                        HelpDialog->Show();
                    }
                    else
                    {
                        HelpDialog->Hide();
                    }

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar14' statement was not added since tempVar14 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar13' statement was not added since tempVar13 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar12' statement was not added since tempVar12 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar11' statement was not added since tempVar11 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar10' statement was not added since tempVar10 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar9' statement was not added since tempVar9 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar8' statement was not added since tempVar8 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar7' statement was not added since tempVar7 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar6' statement was not added since tempVar6 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar5' statement was not added since tempVar5 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar4' statement was not added since tempVar4 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                    break;
                case KeybindOptions::Keybind:
                    if (!KeyboardLayoutDialog->getVisible())
                    {
                        KeyboardLayoutDialog->Show();
                    }
                    else
                    {
                        KeyboardLayoutDialog->Hide();
                    }

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar14' statement was not added since tempVar14 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar13' statement was not added since tempVar13 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar12' statement was not added since tempVar12 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar11' statement was not added since tempVar11 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar10' statement was not added since tempVar10 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar9' statement was not added since tempVar9 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar8' statement was not added since tempVar8 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar7' statement was not added since tempVar7 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar6' statement was not added since tempVar6 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar5' statement was not added since tempVar5 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar4' statement was not added since tempVar4 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                    break;
                case KeybindOptions::Autorun:
                    MapControl->setAutoRun(!MapControl::getAutoRun());
                    break;
                case KeybindOptions::Cameramode:

                    if (!MainDialog->getVisible())
                    {
                        MainDialog->Show();
                        ChatDialog->Show();
                        BeltDialog->Show();
                        ChatControl->Show();
                        MiniMapDialog->Show();
                        CharacterDuraPanel->Show();
                        DuraStatusPanel->Show();
                    }
                    else
                    {
                        MainDialog->Hide();
                        ChatDialog->Hide();
                        BeltDialog->Hide();
                        ChatControl->Hide();
                        MiniMapDialog->Hide();
                        CharacterDuraPanel->Hide();
                        DuraStatusPanel->Hide();
                    }

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar14' statement was not added since tempVar14 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar13' statement was not added since tempVar13 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar12' statement was not added since tempVar12 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar11' statement was not added since tempVar11 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar10' statement was not added since tempVar10 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar9' statement was not added since tempVar9 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar8' statement was not added since tempVar8 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar7' statement was not added since tempVar7 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar6' statement was not added since tempVar6 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar5' statement was not added since tempVar5 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar4' statement was not added since tempVar4 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                    break;
                case KeybindOptions::DropView:
                    if (CMain::Time > DropViewTime)
                    {
                        DropViewTime = CMain::Time + 5000;
                    }

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar14' statement was not added since tempVar14 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar13' statement was not added since tempVar13 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar12' statement was not added since tempVar12 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar11' statement was not added since tempVar11 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar10' statement was not added since tempVar10 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar9' statement was not added since tempVar9 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar8' statement was not added since tempVar8 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar7' statement was not added since tempVar7 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar6' statement was not added since tempVar6 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar5' statement was not added since tempVar5 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar4' statement was not added since tempVar4 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                    break;
                case KeybindOptions::TargetDead:
                    if (CMain::Time > TargetDeadTime)
                    {
                        TargetDeadTime = CMain::Time + 5000;
                    }

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar14' statement was not added since tempVar14 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar13' statement was not added since tempVar13 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar12' statement was not added since tempVar12 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar11' statement was not added since tempVar11 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar10' statement was not added since tempVar10 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar9' statement was not added since tempVar9 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar8' statement was not added since tempVar8 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar7' statement was not added since tempVar7 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar6' statement was not added since tempVar6 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar5' statement was not added since tempVar5 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar4' statement was not added since tempVar4 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                    break;
                case KeybindOptions::AddGroupMember:
                    if (MapObject::MouseObject == nullptr)
                    {
                        break;
                    }
                    if (MapObject::MouseObject->getRace() != ObjectType::Player)
                    {
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar14' statement was not added since tempVar14 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar13' statement was not added since tempVar13 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar12' statement was not added since tempVar12 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar11' statement was not added since tempVar11 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar10' statement was not added since tempVar10 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar9' statement was not added since tempVar9 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar8' statement was not added since tempVar8 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar7' statement was not added since tempVar7 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar6' statement was not added since tempVar6 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar5' statement was not added since tempVar5 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar4' statement was not added since tempVar4 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                        break;
                    }

                    GameScene::Scene->GroupDialog->AddMember(MapObject::MouseObject->Name);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar14' statement was not added since tempVar14 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar13' statement was not added since tempVar13 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar12' statement was not added since tempVar12 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar11' statement was not added since tempVar11 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar10' statement was not added since tempVar10 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar9' statement was not added since tempVar9 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar8' statement was not added since tempVar8 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar7' statement was not added since tempVar7 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar6' statement was not added since tempVar6 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar5' statement was not added since tempVar5 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar4' statement was not added since tempVar4 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                    break;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar14' statement was not added since tempVar14 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar13' statement was not added since tempVar13 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar12' statement was not added since tempVar12 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar11' statement was not added since tempVar11 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar10' statement was not added since tempVar10 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar9' statement was not added since tempVar9 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar8' statement was not added since tempVar8 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar7' statement was not added since tempVar7 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar6' statement was not added since tempVar6 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar5' statement was not added since tempVar5 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar4' statement was not added since tempVar4 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
            }
        }
    }

    void GameScene::ChangeSkillMode(std::optional<bool> &ctrl)
    {
        if (Settings::SkillMode || ctrl == true)
        {
            Settings::SkillMode = false;
            GameScene::Scene->ChatDialog->ReceiveChat("[SkillMode Ctrl]", ChatType::Hint);
            GameScene::Scene->OptionDialog->ToggleSkillButtons(true);
        }
        else if (!Settings::SkillMode || ctrl == false)
        {
            Settings::SkillMode = true;
            GameScene::Scene->ChatDialog->ReceiveChat("[SkillMode ~]", ChatType::Hint);
            GameScene::Scene->OptionDialog->ToggleSkillButtons(false);
        }
    }

    void GameScene::ChangePetMode()
    {
        switch (PMode)
        {
            case PetMode::Both:
                C::ChangePMode *tempVar = new C::ChangePMode();
                tempVar->Mode = PetMode::MoveOnly;
                Network::Enqueue(tempVar);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
                return;
            case PetMode::MoveOnly:
                C::ChangePMode *tempVar2 = new C::ChangePMode();
                tempVar2->Mode = PetMode::AttackOnly;
                Network::Enqueue(tempVar2);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar2' statement was not added since tempVar2 was passed to a method or constructor. Handle memory management manually.
                return;
            case PetMode::AttackOnly:
                C::ChangePMode *tempVar3 = new C::ChangePMode();
                tempVar3->Mode = PetMode::None;
                Network::Enqueue(tempVar3);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                return;
            case PetMode::None:
                C::ChangePMode *tempVar4 = new C::ChangePMode();
                tempVar4->Mode = PetMode::Both;
                Network::Enqueue(tempVar4);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar4' statement was not added since tempVar4 was passed to a method or constructor. Handle memory management manually.
                return;
        }
    }

    void GameScene::ChangeAttackMode()
    {
        switch (AMode)
        {
            case AttackMode::Peace:
                C::ChangeAMode *tempVar = new C::ChangeAMode();
                tempVar->Mode = AttackMode::Group;
                Network::Enqueue(tempVar);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
                return;
            case AttackMode::Group:
                C::ChangeAMode *tempVar2 = new C::ChangeAMode();
                tempVar2->Mode = AttackMode::Guild;
                Network::Enqueue(tempVar2);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar2' statement was not added since tempVar2 was passed to a method or constructor. Handle memory management manually.
                return;
            case AttackMode::Guild:
                C::ChangeAMode *tempVar3 = new C::ChangeAMode();
                tempVar3->Mode = AttackMode::EnemyGuild;
                Network::Enqueue(tempVar3);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                return;
            case AttackMode::EnemyGuild:
                C::ChangeAMode *tempVar4 = new C::ChangeAMode();
                tempVar4->Mode = AttackMode::RedBrown;
                Network::Enqueue(tempVar4);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar4' statement was not added since tempVar4 was passed to a method or constructor. Handle memory management manually.
                return;
            case AttackMode::RedBrown:
                C::ChangeAMode *tempVar5 = new C::ChangeAMode();
                tempVar5->Mode = AttackMode::All;
                Network::Enqueue(tempVar5);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar5' statement was not added since tempVar5 was passed to a method or constructor. Handle memory management manually.
                return;
            case AttackMode::All:
                C::ChangeAMode *tempVar6 = new C::ChangeAMode();
                tempVar6->Mode = AttackMode::Peace;
                Network::Enqueue(tempVar6);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar6' statement was not added since tempVar6 was passed to a method or constructor. Handle memory management manually.
                return;
        }
    }

    void GameScene::UseSpell(int key)
    {
        if (getUser()->RidingMount || getUser()->Fishing)
        {
            return;
        }

        if (!getUser()->getHasClassWeapon() && getUser()->Weapon >= 0)
        {
            ChatDialog->ReceiveChat("You must be wearing a suitable weapon to perform this skill", ChatType::System);
            return;
        }

        if (CMain::Time < getUser()->BlizzardStopTime || CMain::Time < getUser()->ReincarnationStopTime)
        {
            return;
        }

        ClientMagic *magic = nullptr;

        for (int i = 0; i < getUser()->Magics.size(); i++)
        {
            if (getUser()->Magics[i]->Key != key)
            {
                continue;
            }
            magic = getUser()->Magics[i];
            break;
        }

        if (magic == nullptr)
        {
            return;
        }

        switch (magic->Spell)
        {
            case Spell::CounterAttack:
                if ((CMain::Time < magic->CastTime + magic->Delay) && magic->CastTime != 0)
                {
                    if (CMain::Time >= OutputDelay)
                    {
                        OutputDelay = CMain::Time + 1000;
//C# TO C++ CONVERTER TODO TASK: There is no C++ equivalent to 'ToString':
                        GameScene::Scene->OutputMessage(StringHelper::formatSimple("You cannot cast {0} for another {1} seconds.", magic->Spell.ToString(), ((magic->CastTime + magic->Delay) - CMain::Time - 1) / 1000 + 1));
                    }

                    return;
                }
                magic->CastTime = CMain::Time;
                break;
        }

        int cost;
        switch (magic->Spell)
        {
            case Spell::Fencing:
            case Spell::FatalSword:
            case Spell::MPEater:
            case Spell::Hemorrhage:
            case Spell::SpiritSword:
            case Spell::Slaying:
            case Spell::Focus:
            case Spell::Meditation:
                return;
            case Spell::Thrusting:
                if (CMain::Time < ToggleTime)
                {
                    return;
                }
                Thrusting = !Thrusting;
                ChatDialog->ReceiveChat(Thrusting ? "Use Thrusting." : "Do not use Thrusting.", ChatType::Hint);
                ToggleTime = CMain::Time + 1000;
                C::SpellToggle *tempVar = new C::SpellToggle();
                tempVar->Spell = magic->Spell;
                tempVar->CanUse = Thrusting;
                Network::Enqueue(tempVar);
                break;
            case Spell::HalfMoon:
                if (CMain::Time < ToggleTime)
                {
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
                    return;
                }
                HalfMoon = !HalfMoon;
                ChatDialog->ReceiveChat(HalfMoon ? "Use Half Moon." : "Do not use Half Moon.", ChatType::Hint);
                ToggleTime = CMain::Time + 1000;
                C::SpellToggle *tempVar2 = new C::SpellToggle();
                tempVar2->Spell = magic->Spell;
                tempVar2->CanUse = HalfMoon;
                Network::Enqueue(tempVar2);
                break;
            case Spell::CrossHalfMoon:
                if (CMain::Time < ToggleTime)
                {
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar2' statement was not added since tempVar2 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
                    return;
                }
                CrossHalfMoon = !CrossHalfMoon;
                ChatDialog->ReceiveChat(CrossHalfMoon ? "Use Cross Half Moon." : "Do not use Cross Half Moon.", ChatType::Hint);
                ToggleTime = CMain::Time + 1000;
                C::SpellToggle *tempVar3 = new C::SpellToggle();
                tempVar3->Spell = magic->Spell;
                tempVar3->CanUse = CrossHalfMoon;
                Network::Enqueue(tempVar3);
                break;
            case Spell::DoubleSlash:
                if (CMain::Time < ToggleTime)
                {
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar2' statement was not added since tempVar2 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
                    return;
                }
                DoubleSlash = !DoubleSlash;
                ChatDialog->ReceiveChat(DoubleSlash ? "Use Double Slash." : "Do not use Double Slash.", ChatType::Hint);
                ToggleTime = CMain::Time + 1000;
                C::SpellToggle *tempVar4 = new C::SpellToggle();
                tempVar4->Spell = magic->Spell;
                tempVar4->CanUse = DoubleSlash;
                Network::Enqueue(tempVar4);
                break;
            case Spell::TwinDrakeBlade:
                if (CMain::Time < ToggleTime)
                {
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar4' statement was not added since tempVar4 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar2' statement was not added since tempVar2 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
                    return;
                }
                ToggleTime = CMain::Time + 500;

                cost = magic->Level * magic->LevelCost + magic->BaseCost;
                if (cost > MapObject::User->MP)
                {
                    Scene->OutputMessage(GameLanguage::LowMana);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar4' statement was not added since tempVar4 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar2' statement was not added since tempVar2 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
                    return;
                }
                TwinDrakeBlade = true;
                C::SpellToggle *tempVar5 = new C::SpellToggle();
                tempVar5->Spell = magic->Spell;
                tempVar5->CanUse = true;
                Network::Enqueue(tempVar5);
                Effect tempVar6(Libraries::Magic2, 210, 6, 500, getUser());
                getUser()->Effects.push_back(&tempVar6);
                break;
            case Spell::FlamingSword:
                if (CMain::Time < ToggleTime)
                {
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar5' statement was not added since tempVar5 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar4' statement was not added since tempVar4 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar2' statement was not added since tempVar2 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
                    return;
                }
                ToggleTime = CMain::Time + 500;

                cost = magic->Level * magic->LevelCost + magic->BaseCost;
                if (cost > MapObject::User->MP)
                {
                    Scene->OutputMessage(GameLanguage::LowMana);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar5' statement was not added since tempVar5 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar4' statement was not added since tempVar4 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar2' statement was not added since tempVar2 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
                    return;
                }
                C::SpellToggle *tempVar7 = new C::SpellToggle();
                tempVar7->Spell = magic->Spell;
                tempVar7->CanUse = true;
                Network::Enqueue(tempVar7);
                break;
            case Spell::CounterAttack:
                cost = magic->Level * magic->LevelCost + magic->BaseCost;
                if (cost > MapObject::User->MP)
                {
                    Scene->OutputMessage(GameLanguage::LowMana);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar7' statement was not added since tempVar7 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar5' statement was not added since tempVar5 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar4' statement was not added since tempVar4 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar2' statement was not added since tempVar2 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
                    return;
                }

                SoundManager::PlaySound(20000 + static_cast<unsigned short>(Spell::CounterAttack) * 10);
                C::SpellToggle *tempVar8 = new C::SpellToggle();
                tempVar8->Spell = magic->Spell;
                tempVar8->CanUse = true;
                Network::Enqueue(tempVar8);
                break;
            case Spell::MentalState:
                if (CMain::Time < ToggleTime)
                {
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar8' statement was not added since tempVar8 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar7' statement was not added since tempVar7 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar5' statement was not added since tempVar5 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar4' statement was not added since tempVar4 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar2' statement was not added since tempVar2 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
                    return;
                }
                ToggleTime = CMain::Time + 500;
                C::SpellToggle *tempVar9 = new C::SpellToggle();
                tempVar9->Spell = magic->Spell;
                tempVar9->CanUse = true;
                Network::Enqueue(tempVar9);
                break;
            default:
                getUser()->NextMagic = magic;
                getUser()->NextMagicLocation = MapControl::getMapLocation();
                getUser()->NextMagicObject = MapObject::MouseObject;
                getUser()->NextMagicDirection = MapControl::MouseDirection();
                break;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar9' statement was not added since tempVar9 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar8' statement was not added since tempVar8 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar7' statement was not added since tempVar7 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar5' statement was not added since tempVar5 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar4' statement was not added since tempVar4 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar2' statement was not added since tempVar2 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
        }

    }

    void GameScene::QuitGame()
    {
        if (CMain::Time >= LogTime)
        {
            //If Last Combat < 10 CANCEL
            MirMessageBox *messageBox = new MirMessageBox(GameLanguage::ExitTip, MirMessageBoxButtons::YesNo);
            messageBox->YesButton->Click += [&] (o, e)
            {
                Program::Form->Close();
            };
            messageBox->Show();

            delete messageBox;
        }
        else
        {
            ChatDialog->ReceiveChat(std::string::Format(GameLanguage::CannotLeaveGame, (LogTime - CMain::Time) / 1000), ChatType::System);
        }
    }

    void GameScene::LogOut()
    {
        if (CMain::Time >= LogTime)
        {
            //If Last Combat < 10 CANCEL
            MirMessageBox *messageBox = new MirMessageBox(GameLanguage::LogOutTip, MirMessageBoxButtons::YesNo);
            messageBox->YesButton->Click += [&] (o, e)
            {
                C::LogOut tempVar();
                Network::Enqueue(&tempVar);
                setEnabled(false);
            };
            messageBox->Show();

            delete messageBox;
        }
        else
        {
            ChatDialog->ReceiveChat(std::string::Format(GameLanguage::CannotLeaveGame, (LogTime - CMain::Time) / 1000), ChatType::System);
        }
    }

    void GameScene::DrawControl()
    {
        if (MapControl != nullptr && !MapControl->isDisposed())
        {
            MapControl->DrawControl();
        }
        MirScene::DrawControl();


        if (PickedUpGold || (SelectedCell != nullptr && SelectedCell->getItem() != nullptr))
        {
            int image = PickedUpGold ? 116 : SelectedCell->getItem()->getImage();
            Size *imgSize = Libraries::Items->GetTrueSize(image);
            Point *p = Functions::Add(CMain::MPoint, -imgSize->Width / 2, -imgSize->Height / 2);

            if (p->X + imgSize->Width >= Settings::ScreenWidth)
            {
                p->X = Settings::ScreenWidth - imgSize->Width;
            }

            if (p->Y + imgSize->Height >= Settings::ScreenHeight)
            {
                p->Y = Settings::ScreenHeight - imgSize->Height;
            }

            Libraries::Items->Draw(image, p->X, p->Y);
        }

        for (int i = 0; i < OutputLines.size(); i++)
        {
            OutputLines[i]->Draw();
        }
    }

    void GameScene::Process()
    {
        if (MapControl == nullptr || getUser() == nullptr)
        {
            return;
        }

        if (CMain::Time >= MoveTime)
        {
            MoveTime += 100; //Move Speed
            CanMove = true;
            MapControl->AnimationCount++;
            MapControl->TextureValid = false;
        }
        else
        {
            CanMove = false;
        }

        if (CMain::Time >= CMain::NextPing)
        {
            CMain::NextPing = CMain::Time + 60000;
            C::KeepAlive *tempVar = new C::KeepAlive();
            tempVar->Time = CMain::Time;
            Network::Enqueue(tempVar);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
        }

        TimerControl->Process();
        CompassControl->Process();

        MirItemCell *cell = dynamic_cast<MirItemCell*>(MouseControl);

        if (cell != nullptr && HoverItem != cell->getItem() && HoverItem != cell->getShadowItem())
        {
            DisposeItemLabel();
            HoverItem = nullptr;
            CreateItemLabel(cell->getItem());
        }

        if (ItemLabel != nullptr && !ItemLabel->isDisposed())
        {
            ItemLabel->BringToFront();

            int x = CMain::MPoint->X + 15, y = CMain::MPoint->Y;
            if (x + ItemLabel->getSize()->Width > Settings::ScreenWidth)
            {
                x = Settings::ScreenWidth - ItemLabel->getSize()->Width;
            }

            if (y + ItemLabel->getSize()->Height > Settings::ScreenHeight)
            {
                y = Settings::ScreenHeight - ItemLabel->getSize()->Height;
            }
            Point tempVar2(x, y);
            ItemLabel->setLocation(&tempVar2);
        }

        if (MailLabel != nullptr && !MailLabel->isDisposed())
        {
            MailLabel->BringToFront();

            int x = CMain::MPoint->X + 15, y = CMain::MPoint->Y;
            if (x + MailLabel->getSize()->Width > Settings::ScreenWidth)
            {
                x = Settings::ScreenWidth - MailLabel->getSize()->Width;
            }

            if (y + MailLabel->getSize()->Height > Settings::ScreenHeight)
            {
                y = Settings::ScreenHeight - MailLabel->getSize()->Height;
            }
            Point tempVar3(x, y);
            MailLabel->setLocation(&tempVar3);
        }

        if (MemoLabel != nullptr && !MemoLabel->isDisposed())
        {
            MemoLabel->BringToFront();

            int x = CMain::MPoint->X + 15, y = CMain::MPoint->Y;
            if (x + MemoLabel->getSize()->Width > Settings::ScreenWidth)
            {
                x = Settings::ScreenWidth - MemoLabel->getSize()->Width;
            }

            if (y + MemoLabel->getSize()->Height > Settings::ScreenHeight)
            {
                y = Settings::ScreenHeight - MemoLabel->getSize()->Height;
            }
            Point tempVar4(x, y);
            MemoLabel->setLocation(&tempVar4);
        }

        if (GuildBuffLabel != nullptr && !GuildBuffLabel->isDisposed())
        {
            GuildBuffLabel->BringToFront();

            int x = CMain::MPoint->X + 15, y = CMain::MPoint->Y;
            if (x + GuildBuffLabel->getSize()->Width > Settings::ScreenWidth)
            {
                x = Settings::ScreenWidth - GuildBuffLabel->getSize()->Width;
            }

            if (y + GuildBuffLabel->getSize()->Height > Settings::ScreenHeight)
            {
                y = Settings::ScreenHeight - GuildBuffLabel->getSize()->Height;
            }
            Point tempVar5(x, y);
            GuildBuffLabel->setLocation(&tempVar5);
        }

        if (!getUser()->Dead)
        {
            ShowReviveMessage = false;
        }

        if (ShowReviveMessage && CMain::Time > getUser()->DeadTime && getUser()->CurrentAction == MirAction::Dead)
        {
            ShowReviveMessage = false;
            MirMessageBox *messageBox = new MirMessageBox(GameLanguage::DiedTip, MirMessageBoxButtons::YesNo, false);

            messageBox->YesButton->Click += [&] (o, e)
            {
                if (getUser()->Dead)
                {
                    C::TownRevive tempVar6();
                    Network::Enqueue(&tempVar6);
                }
            };

            messageBox->AfterDraw += [&] (o, e)
            {
                if (!getUser()->Dead)
                {
                    messageBox->Dispose();
                }
            };

            messageBox->Show();

            delete messageBox;
        }

        BuffsDialog->Process();

        MapControl->Process();
        MainDialog->Process();
        InventoryDialog->Process();
        CustomPanel1->Process();
        GameShopDialog->Process();
        MiniMapDialog->Process();

        for (auto Bar : *Scene->SkillBarDialogs)
        {
            Bar->Process();
        }

        DialogProcess();

        ProcessOuput();

        UpdateMouseCursor();
    }

    void GameScene::DialogProcess()
    {
        if (Settings::SkillBar)
        {
            for (auto Bar : *Scene->SkillBarDialogs)
            {
                Bar->Show();
            }
        }
        else
        {
            for (auto Bar : *Scene->SkillBarDialogs)
            {
                Bar->Hide();
            }
        }

        for (int i = 0; i < Scene->SkillBarDialogs.size(); i++)
        {
            if (i * 2 > Settings::SkillbarLocation.size())
            {
                break;
            }
            if ((Settings::SkillbarLocation[i][0] > Settings::Resolution - 100) || (Settings::SkillbarLocation[i][1] > 700))
            {
                continue; //in theory you'd want the y coord to be validated based on resolution, but since client only allows for wider screens and not higher :(
            }
            Point tempVar(Settings::SkillbarLocation[i][0], Settings::SkillbarLocation[i][1]);
            Scene->SkillBarDialogs[i]->setLocation(&tempVar);
        }

        if (Settings::DuraView)
        {
            CharacterDuraPanel->Show();
        }
        else
        {
            CharacterDuraPanel->Hide();
        }
    }

    void GameScene::ProcessPacket(Packet *p)
    {
        switch (p->getIndex())
        {
            case static_cast<short>(ServerPacketIds::KeepAlive):
                KeepAlive(static_cast<S::KeepAlive*>(p));
                break;
            case static_cast<short>(ServerPacketIds::MapInformation): //MapInfo
                MapInformation(static_cast<S::MapInformation*>(p));
                break;
            case static_cast<short>(ServerPacketIds::UserInformation):
                UserInformation(static_cast<S::UserInformation*>(p));
                break;
            case static_cast<short>(ServerPacketIds::UserSlotsRefresh):
                UserSlotsRefresh(static_cast<S::UserSlotsRefresh*>(p));
                break;
            case static_cast<short>(ServerPacketIds::UserLocation):
                UserLocation(static_cast<S::UserLocation*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectPlayer):
                ObjectPlayer(static_cast<S::ObjectPlayer*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectRemove):
                ObjectRemove(static_cast<S::ObjectRemove*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectTurn):
                ObjectTurn(static_cast<S::ObjectTurn*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectWalk):
                ObjectWalk(static_cast<S::ObjectWalk*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectRun):
                ObjectRun(static_cast<S::ObjectRun*>(p));
                break;
            case static_cast<short>(ServerPacketIds::Chat):
                ReceiveChat(static_cast<S::Chat*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectChat):
                ObjectChat(static_cast<S::ObjectChat*>(p));
                break;
            case static_cast<short>(ServerPacketIds::MoveItem):
                MoveItem(static_cast<S::MoveItem*>(p));
                break;
            case static_cast<short>(ServerPacketIds::EquipItem):
                EquipItem(static_cast<S::EquipItem*>(p));
                break;
            case static_cast<short>(ServerPacketIds::MergeItem):
                MergeItem(static_cast<S::MergeItem*>(p));
                break;
            case static_cast<short>(ServerPacketIds::RemoveItem):
                RemoveItem(static_cast<S::RemoveItem*>(p));
                break;
            case static_cast<short>(ServerPacketIds::RemoveSlotItem):
                RemoveSlotItem(static_cast<S::RemoveSlotItem*>(p));
                break;
            case static_cast<short>(ServerPacketIds::TakeBackItem):
                TakeBackItem(static_cast<S::TakeBackItem*>(p));
                break;
            case static_cast<short>(ServerPacketIds::StoreItem):
                StoreItem(static_cast<S::StoreItem*>(p));
                break;
            case static_cast<short>(ServerPacketIds::DepositRefineItem):
                DepositRefineItem(static_cast<S::DepositRefineItem*>(p));
                break;
            case static_cast<short>(ServerPacketIds::RetrieveRefineItem):
                RetrieveRefineItem(static_cast<S::RetrieveRefineItem*>(p));
                break;
            case static_cast<short>(ServerPacketIds::RefineCancel):
                RefineCancel(static_cast<S::RefineCancel*>(p));
                break;
            case static_cast<short>(ServerPacketIds::RefineItem):
                RefineItem(static_cast<S::RefineItem*>(p));
                break;
            case static_cast<short>(ServerPacketIds::DepositTradeItem):
                DepositTradeItem(static_cast<S::DepositTradeItem*>(p));
                break;
            case static_cast<short>(ServerPacketIds::RetrieveTradeItem):
                RetrieveTradeItem(static_cast<S::RetrieveTradeItem*>(p));
                break;
            case static_cast<short>(ServerPacketIds::SplitItem):
                SplitItem(static_cast<S::SplitItem*>(p));
                break;
            case static_cast<short>(ServerPacketIds::SplitItem1):
                SplitItem1(static_cast<S::SplitItem1*>(p));
                break;
            case static_cast<short>(ServerPacketIds::UseItem):
                UseItem(static_cast<S::UseItem*>(p));
                break;
            case static_cast<short>(ServerPacketIds::DropItem):
                DropItem(static_cast<S::DropItem*>(p));
                break;
            case static_cast<short>(ServerPacketIds::PlayerUpdate):
                PlayerUpdate(static_cast<S::PlayerUpdate*>(p));
                break;
            case static_cast<short>(ServerPacketIds::PlayerInspect):
                PlayerInspect(static_cast<S::PlayerInspect*>(p));
                break;
            case static_cast<short>(ServerPacketIds::LogOutSuccess):
                LogOutSuccess(static_cast<S::LogOutSuccess*>(p));
                break;
            case static_cast<short>(ServerPacketIds::LogOutFailed):
                LogOutFailed(static_cast<S::LogOutFailed*>(p));
                break;
            case static_cast<short>(ServerPacketIds::TimeOfDay):
                TimeOfDay(static_cast<S::TimeOfDay*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ChangeAMode):
                ChangeAMode(static_cast<S::ChangeAMode*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ChangePMode):
                ChangePMode(static_cast<S::ChangePMode*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectItem):
                ObjectItem(static_cast<S::ObjectItem*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectGold):
                ObjectGold(static_cast<S::ObjectGold*>(p));
                break;
            case static_cast<short>(ServerPacketIds::GainedItem):
                GainedItem(static_cast<S::GainedItem*>(p));
                break;
            case static_cast<short>(ServerPacketIds::GainedGold):
                GainedGold(static_cast<S::GainedGold*>(p));
                break;
            case static_cast<short>(ServerPacketIds::LoseGold):
                LoseGold(static_cast<S::LoseGold*>(p));
                break;
            case static_cast<short>(ServerPacketIds::GainedCredit):
                GainedCredit(static_cast<S::GainedCredit*>(p));
                break;
            case static_cast<short>(ServerPacketIds::LoseCredit):
                LoseCredit(static_cast<S::LoseCredit*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectMonster):
                ObjectMonster(static_cast<S::ObjectMonster*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectAttack):
                ObjectAttack(static_cast<S::ObjectAttack*>(p));
                break;
            case static_cast<short>(ServerPacketIds::Struck):
                Struck(static_cast<S::Struck*>(p));
                break;
            case static_cast<short>(ServerPacketIds::DamageIndicator):
                DamageIndicator(static_cast<S::DamageIndicator*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectStruck):
                ObjectStruck(static_cast<S::ObjectStruck*>(p));
                break;
            case static_cast<short>(ServerPacketIds::DuraChanged):
                DuraChanged(static_cast<S::DuraChanged*>(p));
                break;
            case static_cast<short>(ServerPacketIds::HealthChanged):
                HealthChanged(static_cast<S::HealthChanged*>(p));
                break;
            case static_cast<short>(ServerPacketIds::DeleteItem):
                DeleteItem(static_cast<S::DeleteItem*>(p));
                break;
            case static_cast<short>(ServerPacketIds::Death):
                Death(static_cast<S::Death*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectDied):
                ObjectDied(static_cast<S::ObjectDied*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ColourChanged):
                ColourChanged(static_cast<S::ColourChanged*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectColourChanged):
                ObjectColourChanged(static_cast<S::ObjectColourChanged*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectGuildNameChanged):
                ObjectGuildNameChanged(static_cast<S::ObjectGuildNameChanged*>(p));
                break;
            case static_cast<short>(ServerPacketIds::GainExperience):
                GainExperience(static_cast<S::GainExperience*>(p));
                break;
            case static_cast<short>(ServerPacketIds::LevelChanged):
                LevelChanged(static_cast<S::LevelChanged*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectLeveled):
                ObjectLeveled(static_cast<S::ObjectLeveled*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectHarvest):
                ObjectHarvest(static_cast<S::ObjectHarvest*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectHarvested):
                ObjectHarvested(static_cast<S::ObjectHarvested*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectNpc):
                ObjectNPC(static_cast<S::ObjectNPC*>(p));
                break;
            case static_cast<short>(ServerPacketIds::NPCResponse):
                NPCResponse(static_cast<S::NPCResponse*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectHide):
                ObjectHide(static_cast<S::ObjectHide*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectShow):
                ObjectShow(static_cast<S::ObjectShow*>(p));
                break;
            case static_cast<short>(ServerPacketIds::Poisoned):
                Poisoned(static_cast<S::Poisoned*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectPoisoned):
                ObjectPoisoned(static_cast<S::ObjectPoisoned*>(p));
                break;
            case static_cast<short>(ServerPacketIds::MapChanged):
                MapChanged(static_cast<S::MapChanged*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectTeleportOut):
                ObjectTeleportOut(static_cast<S::ObjectTeleportOut*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectTeleportIn):
                ObjectTeleportIn(static_cast<S::ObjectTeleportIn*>(p));
                break;
            case static_cast<short>(ServerPacketIds::TeleportIn):
                TeleportIn();
                break;
            case static_cast<short>(ServerPacketIds::NPCGoods):
                NPCGoods(static_cast<S::NPCGoods*>(p));
                break;
            case static_cast<short>(ServerPacketIds::NPCSell):
                NPCSell();
                break;
            case static_cast<short>(ServerPacketIds::NPCRepair):
                NPCRepair(static_cast<S::NPCRepair*>(p));
                break;
            case static_cast<short>(ServerPacketIds::NPCSRepair):
                NPCSRepair(static_cast<S::NPCSRepair*>(p));
                break;
            case static_cast<short>(ServerPacketIds::NPCRefine):
                NPCRefine(static_cast<S::NPCRefine*>(p));
                break;
            case static_cast<short>(ServerPacketIds::NPCCheckRefine):
                NPCCheckRefine(static_cast<S::NPCCheckRefine*>(p));
                break;
            case static_cast<short>(ServerPacketIds::NPCCollectRefine):
                NPCCollectRefine(static_cast<S::NPCCollectRefine*>(p));
                break;
            case static_cast<short>(ServerPacketIds::NPCReplaceWedRing):
                NPCReplaceWedRing(static_cast<S::NPCReplaceWedRing*>(p));
                break;
            case static_cast<short>(ServerPacketIds::NPCStorage):
                NPCStorage();
                break;
            case static_cast<short>(ServerPacketIds::NPCRequestInput):
                NPCRequestInput(static_cast<S::NPCRequestInput*>(p));
                break;
            case static_cast<short>(ServerPacketIds::SellItem):
                SellItem(static_cast<S::SellItem*>(p));
                break;
            case static_cast<short>(ServerPacketIds::CraftItem):
                CraftItem(static_cast<S::CraftItem*>(p));
                break;
            case static_cast<short>(ServerPacketIds::RepairItem):
                RepairItem(static_cast<S::RepairItem*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ItemRepaired):
                ItemRepaired(static_cast<S::ItemRepaired*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ItemSlotSizeChanged):
                ItemSlotSizeChanged(static_cast<S::ItemSlotSizeChanged*>(p));
                break;
            case static_cast<short>(ServerPacketIds::NewMagic):
                NewMagic(static_cast<S::NewMagic*>(p));
                break;
            case static_cast<short>(ServerPacketIds::MagicLeveled):
                MagicLeveled(static_cast<S::MagicLeveled*>(p));
                break;
            case static_cast<short>(ServerPacketIds::Magic):
                Magic(static_cast<S::Magic*>(p));
                break;
            case static_cast<short>(ServerPacketIds::MagicDelay):
                MagicDelay(static_cast<S::MagicDelay*>(p));
                break;
            case static_cast<short>(ServerPacketIds::MagicCast):
                MagicCast(static_cast<S::MagicCast*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectMagic):
                ObjectMagic(static_cast<S::ObjectMagic*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectProjectile):
                ObjectProjectile(static_cast<S::ObjectProjectile*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectEffect):
                ObjectEffect(static_cast<S::ObjectEffect*>(p));
                break;
            case static_cast<short>(ServerPacketIds::RangeAttack):
                RangeAttack(static_cast<S::RangeAttack*>(p));
                break;
            case static_cast<short>(ServerPacketIds::Pushed):
                Pushed(static_cast<S::Pushed*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectPushed):
                ObjectPushed(static_cast<S::ObjectPushed*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectName):
                ObjectName(static_cast<S::ObjectName*>(p));
                break;
            case static_cast<short>(ServerPacketIds::UserStorage):
                UserStorage(static_cast<S::UserStorage*>(p));
                break;
            case static_cast<short>(ServerPacketIds::SwitchGroup):
                SwitchGroup(static_cast<S::SwitchGroup*>(p));
                break;
            case static_cast<short>(ServerPacketIds::DeleteGroup):
                DeleteGroup();
                break;
            case static_cast<short>(ServerPacketIds::DeleteMember):
                DeleteMember(static_cast<S::DeleteMember*>(p));
                break;
            case static_cast<short>(ServerPacketIds::GroupInvite):
                GroupInvite(static_cast<S::GroupInvite*>(p));
                break;
            case static_cast<short>(ServerPacketIds::AddMember):
                AddMember(static_cast<S::AddMember*>(p));
                break;
            case static_cast<short>(ServerPacketIds::Revived):
                Revived();
                break;
            case static_cast<short>(ServerPacketIds::ObjectRevived):
                ObjectRevived(static_cast<S::ObjectRevived*>(p));
                break;
            case static_cast<short>(ServerPacketIds::SpellToggle):
                SpellToggle(static_cast<S::SpellToggle*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectHealth):
                ObjectHealth(static_cast<S::ObjectHealth*>(p));
                break;
            case static_cast<short>(ServerPacketIds::MapEffect):
                MapEffect(static_cast<S::MapEffect*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectRangeAttack):
                ObjectRangeAttack(static_cast<S::ObjectRangeAttack*>(p));
                break;
            case static_cast<short>(ServerPacketIds::AddBuff):
                AddBuff(static_cast<S::AddBuff*>(p));
                break;
            case static_cast<short>(ServerPacketIds::RemoveBuff):
                RemoveBuff(static_cast<S::RemoveBuff*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectHidden):
                ObjectHidden(static_cast<S::ObjectHidden*>(p));
                break;
            case static_cast<short>(ServerPacketIds::RefreshItem):
                RefreshItem(static_cast<S::RefreshItem*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectSpell):
                ObjectSpell(static_cast<S::ObjectSpell*>(p));
                break;
            case static_cast<short>(ServerPacketIds::UserDash):
                UserDash(static_cast<S::UserDash*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectDash):
                ObjectDash(static_cast<S::ObjectDash*>(p));
                break;
            case static_cast<short>(ServerPacketIds::UserDashFail):
                UserDashFail(static_cast<S::UserDashFail*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectDashFail):
                ObjectDashFail(static_cast<S::ObjectDashFail*>(p));
                break;
            case static_cast<short>(ServerPacketIds::NPCConsign):
                NPCConsign();
                break;
            case static_cast<short>(ServerPacketIds::NPCMarket):
                NPCMarket(static_cast<S::NPCMarket*>(p));
                break;
            case static_cast<short>(ServerPacketIds::NPCMarketPage):
                NPCMarketPage(static_cast<S::NPCMarketPage*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ConsignItem):
                ConsignItem(static_cast<S::ConsignItem*>(p));
                break;
            case static_cast<short>(ServerPacketIds::MarketFail):
                MarketFail(static_cast<S::MarketFail*>(p));
                break;
            case static_cast<short>(ServerPacketIds::MarketSuccess):
                MarketSuccess(static_cast<S::MarketSuccess*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectSitDown):
                ObjectSitDown(static_cast<S::ObjectSitDown*>(p));
                break;
            case static_cast<short>(ServerPacketIds::InTrapRock):
            {
                S::InTrapRock *packetdata = static_cast<S::InTrapRock*>(p);
                getUser()->InTrapRock = packetdata->Trapped;
                break;
            }
            case static_cast<short>(ServerPacketIds::RemoveMagic):
                RemoveMagic(static_cast<S::RemoveMagic*>(p));
                break;
            case static_cast<short>(ServerPacketIds::BaseStatsInfo):
                BaseStatsInfo(static_cast<S::BaseStatsInfo*>(p));
                break;
            case static_cast<short>(ServerPacketIds::UserName):
                UserName(static_cast<S::UserName*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ChatItemStats):
                ChatItemStats(static_cast<S::ChatItemStats*>(p));
                break;
            case static_cast<short>(ServerPacketIds::GuildInvite):
                GuildInvite(static_cast<S::GuildInvite*>(p));
                break;
            case static_cast<short>(ServerPacketIds::GuildMemberChange):
                GuildMemberChange(static_cast<S::GuildMemberChange*>(p));
                break;
            case static_cast<short>(ServerPacketIds::GuildNoticeChange):
                GuildNoticeChange(static_cast<S::GuildNoticeChange*>(p));
                break;
            case static_cast<short>(ServerPacketIds::GuildStatus):
                GuildStatus(static_cast<S::GuildStatus*>(p));
                break;
            case static_cast<short>(ServerPacketIds::GuildExpGain):
                GuildExpGain(static_cast<S::GuildExpGain*>(p));
                break;
            case static_cast<short>(ServerPacketIds::GuildNameRequest):
                GuildNameRequest(static_cast<S::GuildNameRequest*>(p));
                break;
            case static_cast<short>(ServerPacketIds::GuildStorageGoldChange):
                GuildStorageGoldChange(static_cast<S::GuildStorageGoldChange*>(p));
                break;
            case static_cast<short>(ServerPacketIds::GuildStorageItemChange):
                GuildStorageItemChange(static_cast<S::GuildStorageItemChange*>(p));
                break;
            case static_cast<short>(ServerPacketIds::GuildStorageList):
                GuildStorageList(static_cast<S::GuildStorageList*>(p));
                break;
            case static_cast<short>(ServerPacketIds::GuildRequestWar):
                GuildRequestWar(static_cast<S::GuildRequestWar*>(p));
                break;
            case static_cast<short>(ServerPacketIds::DefaultNPC):
                DefaultNPC(static_cast<S::DefaultNPC*>(p));
                break;
            case static_cast<short>(ServerPacketIds::NPCUpdate):
                NPCUpdate(static_cast<S::NPCUpdate*>(p));
                break;
            case static_cast<short>(ServerPacketIds::NPCImageUpdate):
                NPCImageUpdate(static_cast<S::NPCImageUpdate*>(p));
                break;
            case static_cast<short>(ServerPacketIds::MarriageRequest):
                MarriageRequest(static_cast<S::MarriageRequest*>(p));
                break;
            case static_cast<short>(ServerPacketIds::DivorceRequest):
                DivorceRequest(static_cast<S::DivorceRequest*>(p));
                break;
            case static_cast<short>(ServerPacketIds::MentorRequest):
                MentorRequest(static_cast<S::MentorRequest*>(p));
                break;
            case static_cast<short>(ServerPacketIds::TradeRequest):
                TradeRequest(static_cast<S::TradeRequest*>(p));
                break;
            case static_cast<short>(ServerPacketIds::TradeAccept):
                TradeAccept(static_cast<S::TradeAccept*>(p));
                break;
            case static_cast<short>(ServerPacketIds::TradeGold):
                TradeGold(static_cast<S::TradeGold*>(p));
                break;
            case static_cast<short>(ServerPacketIds::TradeItem):
                TradeItem(static_cast<S::TradeItem*>(p));
                break;
            case static_cast<short>(ServerPacketIds::TradeConfirm):
                TradeConfirm();
                break;
            case static_cast<short>(ServerPacketIds::TradeCancel):
                TradeCancel(static_cast<S::TradeCancel*>(p));
                break;
            case static_cast<short>(ServerPacketIds::MountUpdate):
                MountUpdate(static_cast<S::MountUpdate*>(p));
                break;
            case static_cast<short>(ServerPacketIds::TransformUpdate):
                TransformUpdate(static_cast<S::TransformUpdate*>(p));
                break;
            case static_cast<short>(ServerPacketIds::EquipSlotItem):
                EquipSlotItem(static_cast<S::EquipSlotItem*>(p));
                break;
            case static_cast<short>(ServerPacketIds::FishingUpdate):
                FishingUpdate(static_cast<S::FishingUpdate*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ChangeQuest):
                ChangeQuest(static_cast<S::ChangeQuest*>(p));
                break;
            case static_cast<short>(ServerPacketIds::CompleteQuest):
                CompleteQuest(static_cast<S::CompleteQuest*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ShareQuest):
                ShareQuest(static_cast<S::ShareQuest*>(p));
                break;
            case static_cast<short>(ServerPacketIds::GainedQuestItem):
                GainedQuestItem(static_cast<S::GainedQuestItem*>(p));
                break;
            case static_cast<short>(ServerPacketIds::DeleteQuestItem):
                DeleteQuestItem(static_cast<S::DeleteQuestItem*>(p));
                break;
            case static_cast<short>(ServerPacketIds::CancelReincarnation):
                getUser()->ReincarnationStopTime = 0;
                break;
            case static_cast<short>(ServerPacketIds::RequestReincarnation):
                if (!getUser()->Dead)
                {
                    return;
                }
                RequestReincarnation();
                break;
            case static_cast<short>(ServerPacketIds::UserBackStep):
                UserBackStep(static_cast<S::UserBackStep*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectBackStep):
                ObjectBackStep(static_cast<S::ObjectBackStep*>(p));
                break;
            case static_cast<short>(ServerPacketIds::UserDashAttack):
                UserDashAttack(static_cast<S::UserDashAttack*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectDashAttack):
                ObjectDashAttack(static_cast<S::ObjectDashAttack*>(p));
                break;
            case static_cast<short>(ServerPacketIds::UserAttackMove): //Warrior Skill - SlashingBurst
                UserAttackMove(static_cast<S::UserAttackMove*>(p));
                break;
            case static_cast<short>(ServerPacketIds::CombineItem):
                CombineItem(static_cast<S::CombineItem*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ItemUpgraded):
                ItemUpgraded(static_cast<S::ItemUpgraded*>(p));
                break;
            case static_cast<short>(ServerPacketIds::SetConcentration):
                SetConcentration(static_cast<S::SetConcentration*>(p));
                break;
            case static_cast<short>(ServerPacketIds::SetElemental):
                SetElemental(static_cast<S::SetElemental*>(p));
                break;
            case static_cast<short>(ServerPacketIds::RemoveDelayedExplosion):
                RemoveDelayedExplosion(static_cast<S::RemoveDelayedExplosion*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectDeco):
                ObjectDeco(static_cast<S::ObjectDeco*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectSneaking):
                ObjectSneaking(static_cast<S::ObjectSneaking*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ObjectLevelEffects):
                ObjectLevelEffects(static_cast<S::ObjectLevelEffects*>(p));
                break;
            case static_cast<short>(ServerPacketIds::SetBindingShot):
                SetBindingShot(static_cast<S::SetBindingShot*>(p));
                break;
            case static_cast<short>(ServerPacketIds::SendOutputMessage):
                SendOutputMessage(static_cast<S::SendOutputMessage*>(p));
                break;
            case static_cast<short>(ServerPacketIds::NPCAwakening):
                NPCAwakening();
                break;
            case static_cast<short>(ServerPacketIds::NPCDisassemble):
                NPCDisassemble();
                break;
            case static_cast<short>(ServerPacketIds::NPCDowngrade):
                NPCDowngrade();
                break;
            case static_cast<short>(ServerPacketIds::NPCReset):
                NPCReset();
                break;
            case static_cast<short>(ServerPacketIds::AwakeningNeedMaterials):
                AwakeningNeedMaterials(static_cast<S::AwakeningNeedMaterials*>(p));
                break;
            case static_cast<short>(ServerPacketIds::AwakeningLockedItem):
                AwakeningLockedItem(static_cast<S::AwakeningLockedItem*>(p));
                break;
            case static_cast<short>(ServerPacketIds::Awakening):
                Awakening(static_cast<S::Awakening*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ReceiveMail):
                ReceiveMail(static_cast<S::ReceiveMail*>(p));
                break;
            case static_cast<short>(ServerPacketIds::MailLockedItem):
                MailLockedItem(static_cast<S::MailLockedItem*>(p));
                break;
            case static_cast<short>(ServerPacketIds::MailSent):
                MailSent(static_cast<S::MailSent*>(p));
                break;
            case static_cast<short>(ServerPacketIds::MailSendRequest):
                MailSendRequest(static_cast<S::MailSendRequest*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ParcelCollected):
                ParcelCollected(static_cast<S::ParcelCollected*>(p));
                break;
            case static_cast<short>(ServerPacketIds::MailCost):
                MailCost(static_cast<S::MailCost*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ResizeInventory):
                ResizeInventory(static_cast<S::ResizeInventory*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ResizeStorage):
                ResizeStorage(static_cast<S::ResizeStorage*>(p));
                break;
            case static_cast<short>(ServerPacketIds::NewIntelligentCreature):
                NewIntelligentCreature(static_cast<S::NewIntelligentCreature*>(p));
                break;
            case static_cast<short>(ServerPacketIds::UpdateIntelligentCreatureList):
                UpdateIntelligentCreatureList(static_cast<S::UpdateIntelligentCreatureList*>(p));
                break;
            case static_cast<short>(ServerPacketIds::IntelligentCreatureEnableRename):
                IntelligentCreatureEnableRename(static_cast<S::IntelligentCreatureEnableRename*>(p));
                break;
            case static_cast<short>(ServerPacketIds::IntelligentCreaturePickup):
                IntelligentCreaturePickup(static_cast<S::IntelligentCreaturePickup*>(p));
                break;
            case static_cast<short>(ServerPacketIds::NPCPearlGoods):
                NPCPearlGoods(static_cast<S::NPCPearlGoods*>(p));
                break;
            case static_cast<short>(ServerPacketIds::FriendUpdate):
                FriendUpdate(static_cast<S::FriendUpdate*>(p));
                break;
            case static_cast<short>(ServerPacketIds::LoverUpdate):
                LoverUpdate(static_cast<S::LoverUpdate*>(p));
                break;
            case static_cast<short>(ServerPacketIds::MentorUpdate):
                MentorUpdate(static_cast<S::MentorUpdate*>(p));
                break;
            case static_cast<short>(ServerPacketIds::GuildBuffList):
                GuildBuffList(static_cast<S::GuildBuffList*>(p));
                break;
            case static_cast<short>(ServerPacketIds::GameShopInfo):
                GameShopUpdate(static_cast<S::GameShopInfo*>(p));
                break;
            case static_cast<short>(ServerPacketIds::GameShopStock):
                GameShopStock(static_cast<S::GameShopStock*>(p));
                break;
            case static_cast<short>(ServerPacketIds::Rankings):
                Rankings(static_cast<S::Rankings*>(p));
                break;
            case static_cast<short>(ServerPacketIds::Opendoor):
                Opendoor(static_cast<S::Opendoor*>(p));
                break;
            case static_cast<short>(ServerPacketIds::GetRentedItems):
                RentedItems(static_cast<S::GetRentedItems*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ItemRentalRequest):
                ItemRentalRequest(static_cast<S::ItemRentalRequest*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ItemRentalFee):
                ItemRentalFee(static_cast<S::ItemRentalFee*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ItemRentalPeriod):
                ItemRentalPeriod(static_cast<S::ItemRentalPeriod*>(p));
                break;
            case static_cast<short>(ServerPacketIds::DepositRentalItem):
                DepositRentalItem(static_cast<S::DepositRentalItem*>(p));
                break;
            case static_cast<short>(ServerPacketIds::RetrieveRentalItem):
                RetrieveRentalItem(static_cast<S::RetrieveRentalItem*>(p));
                break;
            case static_cast<short>(ServerPacketIds::UpdateRentalItem):
                UpdateRentalItem(static_cast<S::UpdateRentalItem*>(p));
                break;
            case static_cast<short>(ServerPacketIds::CancelItemRental):
                CancelItemRental(static_cast<S::CancelItemRental*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ItemRentalLock):
                ItemRentalLock(static_cast<S::ItemRentalLock*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ItemRentalPartnerLock):
                ItemRentalPartnerLock(static_cast<S::ItemRentalPartnerLock*>(p));
                break;
            case static_cast<short>(ServerPacketIds::CanConfirmItemRental):
                CanConfirmItemRental(static_cast<S::CanConfirmItemRental*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ConfirmItemRental):
                ConfirmItemRental(static_cast<S::ConfirmItemRental*>(p));
                break;
            case static_cast<short>(ServerPacketIds::OpenBrowser):
                OpenBrowser(static_cast<S::OpenBrowser*>(p));
                break;
            case static_cast<short>(ServerPacketIds::PlaySound):
                PlaySound(static_cast<S::PlaySound*>(p));
                break;
            case static_cast<short>(ServerPacketIds::SetTimer):
                SetTimer(static_cast<S::SetTimer*>(p));
                break;
            case static_cast<short>(ServerPacketIds::ExpireTimer):
                ExpireTimer(static_cast<S::ExpireTimer*>(p));
                break;
            case static_cast<short>(ServerPacketIds::UpdateNotice):
                ShowNotice(static_cast<S::UpdateNotice*>(p));
                break;
            default:
                MirScene::ProcessPacket(p);
                break;
        }
    }

    void GameScene::KeepAlive(S::KeepAlive *p)
    {
        if (p->Time == 0)
        {
            return;
        }
        CMain::PingTime = (CMain::Time - p->Time);
    }

    void GameScene::MapInformation(S::MapInformation *p)
    {
        if (MapControl != nullptr && !MapControl->isDisposed())
        {
            MapControl->Dispose();
        }
        MapControl = new MapControl();
        MapControl->FileName = FileSystem::combine(Settings::MapPath, p->FileName + ".map");
        MapControl->Title = p->Title;
        MapControl->MiniMap = p->MiniMap;
        MapControl->BigMap = p->BigMap;
        MapControl->Lights = p->Lights;
        MapControl->Lightning = p->Lightning;
        MapControl->Fire = p->Fire;
        MapControl->MapDarkLight = p->MapDarkLight;
        MapControl->Music = p->Music;
        MapControl->LoadMap();
        InsertControl(0, MapControl);
    }

    void GameScene::UserInformation(S::UserInformation *p)
    {
        UserObject tempVar(p->ObjectID);
        setUser(&tempVar);
        getUser()->Load(p);
        MainDialog->PModeLabel->setVisible(getUser()->Class == MirClass::Wizard || getUser()->Class == MirClass::Taoist);
        Gold = p->Gold;
        Credit = p->Credit;

        InventoryDialog->RefreshInventory();
        for (auto Bar : SkillBarDialogs)
        {
            Bar->Update();
        }
    }

    void GameScene::UserSlotsRefresh(S::UserSlotsRefresh *p)
    {
        getUser()->SetSlots(p);
    }

    void GameScene::UserLocation(S::UserLocation *p)
    {
        MapControl::NextAction = 0;
        if (getUser()->CurrentLocation == p->Location && getUser()->Direction == p->Direction)
        {
            return;
        }

        if (Settings::DebugMode)
        {
            S::Chat *tempVar = new S::Chat();
            tempVar->Message = "Displacement";
            tempVar->Type = ChatType::System;
            ReceiveChat(tempVar);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
        }

        MapControl->RemoveObject(getUser());
        getUser()->CurrentLocation = p->Location;
        getUser()->MapLocation = p->Location;
        MapControl->AddObject(getUser());

        MapControl->FloorValid = false;
        MapControl::InputDelay = CMain::Time + 400;

        if (getUser()->Dead)
        {
            return;
        }

        getUser()->ClearMagic();
        getUser()->QueuedAction = nullptr;

        for (int i = getUser()->ActionFeed.size() - 1; i >= 0; i--)
        {
            if (getUser()->ActionFeed[i]->Action == MirAction::Pushed)
            {
                continue;
            }
            getUser()->ActionFeed.erase(getUser()->ActionFeed.begin() + i);
        }

        getUser()->SetAction();
    }

    void GameScene::ReceiveChat(S::Chat *p)
    {
        ChatDialog->ReceiveChat(p->Message, p->Type);
    }

    void GameScene::ObjectPlayer(S::ObjectPlayer *p)
    {
        PlayerObject *player = new PlayerObject(p->ObjectID);
        player->Load(p);

        delete player;
    }

    void GameScene::ObjectRemove(S::ObjectRemove *p)
    {
        if (p->ObjectID == getUser()->ObjectID)
        {
            return;
        }

        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];
            if (ob->ObjectID != p->ObjectID)
            {
                continue;
            }
            ob->Remove();
        }
    }

    void GameScene::ObjectTurn(S::ObjectTurn *p)
    {
        if (p->ObjectID == getUser()->ObjectID)
        {
            return;
        }

        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];
            if (ob->ObjectID != p->ObjectID)
            {
                continue;
            }
            QueuedAction *tempVar = new QueuedAction();
            tempVar->Action = MirAction::Standing;
            tempVar->Direction = p->Direction;
            tempVar->Location = p->Location;
            ob->ActionFeed.push_back(tempVar);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
            return;
        }
    }

    void GameScene::ObjectWalk(S::ObjectWalk *p)
    {
        if (p->ObjectID == getUser()->ObjectID)
        {
            return;
        }

        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];
            if (ob->ObjectID != p->ObjectID)
            {
                continue;
            }
            QueuedAction *tempVar = new QueuedAction();
            tempVar->Action = MirAction::Walking;
            tempVar->Direction = p->Direction;
            tempVar->Location = p->Location;
            ob->ActionFeed.push_back(tempVar);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
            return;
        }
    }

    void GameScene::ObjectRun(S::ObjectRun *p)
    {
        if (p->ObjectID == getUser()->ObjectID)
        {
            return;
        }

        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];
            if (ob->ObjectID != p->ObjectID)
            {
                continue;
            }
            QueuedAction *tempVar = new QueuedAction();
            tempVar->Action = MirAction::Running;
            tempVar->Direction = p->Direction;
            tempVar->Location = p->Location;
            ob->ActionFeed.push_back(tempVar);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
            return;
        }
    }

    void GameScene::ObjectChat(S::ObjectChat *p)
    {
        ChatDialog->ReceiveChat(p->Text, p->Type);

        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];
            if (ob->ObjectID != p->ObjectID)
            {
                continue;
            }
            ob->Chat(RegexFunctions::CleanChatString(p->Text));
            return;
        }

    }

    void GameScene::MoveItem(S::MoveItem *p)
    {
        MirItemCell *toCell, *fromCell;

        switch (p->Grid)
        {
            case MirGridType::Inventory:
                fromCell = p->From < getUser()->BeltIdx ? BeltDialog->Grid[p->From] : InventoryDialog->Grid[p->From - getUser()->BeltIdx];
                break;
            case MirGridType::Storage:
                fromCell = StorageDialog->Grid[p->From];
                break;
            case MirGridType::Trade:
                fromCell = TradeDialog->Grid[p->From];
                break;
            case MirGridType::Refine:
                fromCell = RefineDialog->Grid[p->From];
                break;
            default:
                return;
        }

        switch (p->Grid)
        {
            case MirGridType::Inventory:
                toCell = p->To < getUser()->BeltIdx ? BeltDialog->Grid[p->To] : InventoryDialog->Grid[p->To - getUser()->BeltIdx];
                break;
            case MirGridType::Storage:
                toCell = StorageDialog->Grid[p->To];
                break;
            case MirGridType::Trade:
                toCell = TradeDialog->Grid[p->To];
                break;
            case MirGridType::Refine:
                toCell = RefineDialog->Grid[p->To];
                break;
            default:
                return;
        }

        if (toCell == nullptr || fromCell == nullptr)
        {
            return;
        }

        toCell->setLocked(false);
        fromCell->setLocked(false);

        if (p->Grid == MirGridType::Trade)
        {
            TradeDialog->ChangeLockState(false);
        }

        if (!p->Success)
        {
            return;
        }

        UserItem *i = fromCell->getItem();
        fromCell->setItem(toCell->getItem());
        toCell->setItem(i);

        getUser()->RefreshStats();
        CharacterDuraPanel->GetCharacterDura();
    }

    void GameScene::EquipItem(S::EquipItem *p)
    {
        MirItemCell *fromCell;

        MirItemCell *toCell = CharacterDialog->Grid[p->To];

        switch (p->Grid)
        {
            case MirGridType::Inventory:
                Client.MirControls.MirItemCell tempVar = InventoryDialog.GetCell(p.UniqueID);
                fromCell = (tempVar != nullptr) ? tempVar : BeltDialog->GetCell(p->UniqueID);
                break;
            case MirGridType::Storage:
                Client.MirControls.MirItemCell tempVar2 = StorageDialog.GetCell(p.UniqueID);
                fromCell = (tempVar2 != nullptr) ? tempVar2 : BeltDialog->GetCell(p->UniqueID);
                break;
            default:
                return;
        }

        if (toCell == nullptr || fromCell == nullptr)
        {
            return;
        }

        toCell->setLocked(false);
        fromCell->setLocked(false);

        if (!p->Success)
        {
            return;
        }

        UserItem *i = fromCell->getItem();
        fromCell->setItem(toCell->getItem());
        toCell->setItem(i);
        CharacterDuraPanel->UpdateCharacterDura(i);
        getUser()->RefreshStats();
    }

    void GameScene::EquipSlotItem(S::EquipSlotItem *p)
    {
        MirItemCell *fromCell;
        MirItemCell *toCell;

        switch (p->GridTo)
        {
            case MirGridType::Socket:
                toCell = SocketDialog->Grid[p->To];
                break;
            case MirGridType::Mount:
                toCell = MountDialog->Grid[p->To];
                break;
            case MirGridType::Fishing:
                toCell = FishingDialog->Grid[p->To];
                break;
            default:
                return;
        }

        switch (p->Grid)
        {
            case MirGridType::Inventory:
                Client.MirControls.MirItemCell tempVar = InventoryDialog.GetCell(p.UniqueID);
                fromCell = (tempVar != nullptr) ? tempVar : BeltDialog->GetCell(p->UniqueID);
                break;
            case MirGridType::Storage:
                Client.MirControls.MirItemCell tempVar2 = StorageDialog.GetCell(p.UniqueID);
                fromCell = (tempVar2 != nullptr) ? tempVar2 : BeltDialog->GetCell(p->UniqueID);
                break;
            default:
                return;
        }

        //if (toCell == null || fromCell == null) return;

        toCell->setLocked(false);
        fromCell->setLocked(false);

        if (!p->Success)
        {
            return;
        }

        UserItem *i = fromCell->getItem();
        fromCell->setItem(nullptr);
        toCell->setItem(i);
        getUser()->RefreshStats();
    }

    void GameScene::CombineItem(S::CombineItem *p)
    {
        Client.MirControls.MirItemCell tempVar = InventoryDialog.GetCell(p.IDFrom);
        MirItemCell *fromCell = (tempVar != nullptr) ? tempVar : BeltDialog->GetCell(p->IDFrom);
        Client.MirControls.MirItemCell tempVar2 = InventoryDialog.GetCell(p.IDTo);
        MirItemCell *toCell = (tempVar2 != nullptr) ? tempVar2 : BeltDialog->GetCell(p->IDTo);

        if (toCell == nullptr || fromCell == nullptr)
        {
            return;
        }

        toCell->setLocked(false);
        fromCell->setLocked(false);

        if (p->Destroy)
        {
            toCell->setItem(nullptr);
        }

        if (!p->Success)
        {
            return;
        }

        fromCell->setItem(nullptr);

        getUser()->RefreshStats();
    }

    void GameScene::MergeItem(S::MergeItem *p)
    {
        MirItemCell *toCell, *fromCell;

        switch (p->GridFrom)
        {
            case MirGridType::Inventory:
                Client.MirControls.MirItemCell tempVar = InventoryDialog.GetCell(p.IDFrom);
                fromCell = (tempVar != nullptr) ? tempVar : BeltDialog->GetCell(p->IDFrom);
                break;
            case MirGridType::Storage:
                fromCell = StorageDialog->GetCell(p->IDFrom);
                break;
            case MirGridType::Equipment:
                fromCell = CharacterDialog->GetCell(p->IDFrom);
                break;
            case MirGridType::Trade:
                fromCell = TradeDialog->GetCell(p->IDFrom);
                break;
            case MirGridType::Fishing:
                fromCell = FishingDialog->GetCell(p->IDFrom);
                break;
            default:
                return;
        }

        switch (p->GridTo)
        {
            case MirGridType::Inventory:
                Client.MirControls.MirItemCell tempVar2 = InventoryDialog.GetCell(p.IDTo);
                toCell = (tempVar2 != nullptr) ? tempVar2 : BeltDialog->GetCell(p->IDTo);
                break;
            case MirGridType::Storage:
                toCell = StorageDialog->GetCell(p->IDTo);
                break;
            case MirGridType::Equipment:
                toCell = CharacterDialog->GetCell(p->IDTo);
                break;
            case MirGridType::Trade:
                toCell = TradeDialog->GetCell(p->IDTo);
                break;
            case MirGridType::Fishing:
                toCell = FishingDialog->GetCell(p->IDTo);
                break;
            default:
                return;
        }

        if (toCell == nullptr || fromCell == nullptr)
        {
            return;
        }

        toCell->setLocked(false);
        fromCell->setLocked(false);

        if (p->GridFrom == MirGridType::Trade || p->GridTo == MirGridType::Trade)
        {
            TradeDialog->ChangeLockState(false);
        }

        if (!p->Success)
        {
            return;
        }
        if (fromCell->getItem()->Count <= toCell->getItem()->Info->StackSize - toCell->getItem()->Count)
        {
            toCell->getItem()->Count += fromCell->getItem()->Count;
            fromCell->setItem(nullptr);
        }
        else
        {
            fromCell->getItem()->Count -= static_cast<unsigned short>(toCell->getItem()->Info->StackSize - toCell->getItem()->Count);
            toCell->getItem()->Count = toCell->getItem()->Info->StackSize;
        }

        getUser()->RefreshStats();
    }

    void GameScene::RemoveItem(S::RemoveItem *p)
    {
        MirItemCell *toCell;

        int index = -1;

        for (int i = 0; i < MapObject::User->Equipment.size(); i++)
        {
            if (MapObject::User->Equipment[i] == nullptr || MapObject::User->Equipment[i]->UniqueID != p->UniqueID)
            {
                continue;
            }
            index = i;
            break;
        }

        MirItemCell *fromCell = CharacterDialog->Grid[index];


        switch (p->Grid)
        {
            case MirGridType::Inventory:
                toCell = p->To < getUser()->BeltIdx ? BeltDialog->Grid[p->To] : InventoryDialog->Grid[p->To - getUser()->BeltIdx];
                break;
            case MirGridType::Storage:
                toCell = StorageDialog->Grid[p->To];
                break;
            default:
                return;
        }

        if (toCell == nullptr || fromCell == nullptr)
        {
            return;
        }

        toCell->setLocked(false);
        fromCell->setLocked(false);

        if (!p->Success)
        {
            return;
        }
        toCell->setItem(fromCell->getItem());
        fromCell->setItem(nullptr);
        CharacterDuraPanel->GetCharacterDura();
        getUser()->RefreshStats();
    }

    void GameScene::RemoveSlotItem(S::RemoveSlotItem *p)
    {
        MirItemCell *fromCell;
        MirItemCell *toCell;

        int index = -1;

        switch (p->Grid)
        {
            case MirGridType::Socket:
                fromCell = SocketDialog->GetCell(p->UniqueID);
                break;
            case MirGridType::Mount:
                fromCell = MountDialog->GetCell(p->UniqueID);
                break;
            case MirGridType::Fishing:
                fromCell = FishingDialog->GetCell(p->UniqueID);
                break;
            default:
                return;
        }

        switch (p->GridTo)
        {
            case MirGridType::Inventory:
                toCell = p->To < getUser()->BeltIdx ? BeltDialog->Grid[p->To] : InventoryDialog->Grid[p->To - getUser()->BeltIdx];
                break;
            case MirGridType::Storage:
                toCell = StorageDialog->Grid[p->To];
                break;
            default:
                return;
        }

        if (toCell == nullptr || fromCell == nullptr)
        {
            return;
        }

        toCell->setLocked(false);
        fromCell->setLocked(false);

        if (!p->Success)
        {
            return;
        }
        toCell->setItem(fromCell->getItem());
        fromCell->setItem(nullptr);
        CharacterDuraPanel->GetCharacterDura();
        getUser()->RefreshStats();
    }

    void GameScene::TakeBackItem(S::TakeBackItem *p)
    {
        MirItemCell *fromCell = StorageDialog->Grid[p->From];

        MirItemCell *toCell = p->To < getUser()->BeltIdx ? BeltDialog->Grid[p->To] : InventoryDialog->Grid[p->To - getUser()->BeltIdx];

        if (toCell == nullptr || fromCell == nullptr)
        {
            return;
        }

        toCell->setLocked(false);
        fromCell->setLocked(false);

        if (!p->Success)
        {
            return;
        }
        toCell->setItem(fromCell->getItem());
        fromCell->setItem(nullptr);
        getUser()->RefreshStats();
        CharacterDuraPanel->GetCharacterDura();
    }

    void GameScene::StoreItem(S::StoreItem *p)
    {
        MirItemCell *fromCell = p->From < getUser()->BeltIdx ? BeltDialog->Grid[p->From] : InventoryDialog->Grid[p->From - getUser()->BeltIdx];

        MirItemCell *toCell = StorageDialog->Grid[p->To];

        if (toCell == nullptr || fromCell == nullptr)
        {
            return;
        }

        toCell->setLocked(false);
        fromCell->setLocked(false);

        if (!p->Success)
        {
            return;
        }
        toCell->setItem(fromCell->getItem());
        fromCell->setItem(nullptr);
        getUser()->RefreshStats();
    }

    void GameScene::DepositRefineItem(S::DepositRefineItem *p)
    {
        MirItemCell *fromCell = p->From < getUser()->BeltIdx ? BeltDialog->Grid[p->From] : InventoryDialog->Grid[p->From - getUser()->BeltIdx];

        MirItemCell *toCell = RefineDialog->Grid[p->To];

        if (toCell == nullptr || fromCell == nullptr)
        {
            return;
        }

        toCell->setLocked(false);
        fromCell->setLocked(false);

        if (!p->Success)
        {
            return;
        }
        toCell->setItem(fromCell->getItem());
        fromCell->setItem(nullptr);
        getUser()->RefreshStats();
    }

    void GameScene::RetrieveRefineItem(S::RetrieveRefineItem *p)
    {
        MirItemCell *fromCell = RefineDialog->Grid[p->From];
        MirItemCell *toCell = p->To < getUser()->BeltIdx ? BeltDialog->Grid[p->To] : InventoryDialog->Grid[p->To - getUser()->BeltIdx];

        if (toCell == nullptr || fromCell == nullptr)
        {
            return;
        }

        toCell->setLocked(false);
        fromCell->setLocked(false);

        if (!p->Success)
        {
            return;
        }
        toCell->setItem(fromCell->getItem());
        fromCell->setItem(nullptr);
        getUser()->RefreshStats();
    }

    void GameScene::RefineCancel(S::RefineCancel *p)
    {
        RefineDialog->RefineReset();
    }

    void GameScene::RefineItem(S::RefineItem *p)
    {
        RefineDialog->RefineReset();
        for (int i = 0; i < getUser()->Inventory.size(); i++)
        {
            if (getUser()->Inventory[i] != nullptr && getUser()->Inventory[i]->UniqueID == p->UniqueID)
            {
                getUser()->Inventory[i] = nullptr;
                break;
            }
        }
        NPCDialog->Hide();
    }

    void GameScene::DepositTradeItem(S::DepositTradeItem *p)
    {
        MirItemCell *fromCell = p->From < getUser()->BeltIdx ? BeltDialog->Grid[p->From] : InventoryDialog->Grid[p->From - getUser()->BeltIdx];

        MirItemCell *toCell = TradeDialog->Grid[p->To];

        if (toCell == nullptr || fromCell == nullptr)
        {
            return;
        }

        toCell->setLocked(false);
        fromCell->setLocked(false);
        TradeDialog->ChangeLockState(false);

        if (!p->Success)
        {
            return;
        }
        toCell->setItem(fromCell->getItem());
        fromCell->setItem(nullptr);
        getUser()->RefreshStats();
    }

    void GameScene::RetrieveTradeItem(S::RetrieveTradeItem *p)
    {
        MirItemCell *fromCell = TradeDialog->Grid[p->From];
        MirItemCell *toCell = p->To < getUser()->BeltIdx ? BeltDialog->Grid[p->To] : InventoryDialog->Grid[p->To - getUser()->BeltIdx];

        if (toCell == nullptr || fromCell == nullptr)
        {
            return;
        }

        toCell->setLocked(false);
        fromCell->setLocked(false);
        TradeDialog->ChangeLockState(false);

        if (!p->Success)
        {
            return;
        }
        toCell->setItem(fromCell->getItem());
        fromCell->setItem(nullptr);
        getUser()->RefreshStats();
    }

    void GameScene::SplitItem(S::SplitItem *p)
    {
        Bind(p->Item);

        std::vector<UserItem*> array;
        switch (p->Grid)
        {
            case MirGridType::Inventory:
                array = MapObject::User->Inventory;
                break;
            case MirGridType::Storage:
                array = Storage;
                break;
            default:
                return;
        }

        if (p->Grid == MirGridType::Inventory && (p->Item->Info->Type == ItemType::Potion || p->Item->Info->Type == ItemType::Scroll || p->Item->Info->Type == ItemType::Amulet || (p->Item->Info->Type == ItemType::Script && p->Item->Info->Effect == 1)))
        {
            if (p->Item->Info->Type == ItemType::Potion || p->Item->Info->Type == ItemType::Scroll || (p->Item->Info->Type == ItemType::Script && p->Item->Info->Effect == 1))
            {
                for (int i = 0; i < 4; i++)
                {
                    if (array[i] != nullptr)
                    {
                        continue;
                    }
                    array[i] = p->Item;
                    getUser()->RefreshStats();
                    return;
                }
            }
            else if (p->Item->Info->Type == ItemType::Amulet)
            {
                for (int i = 4; i < GameScene::getUser()->BeltIdx; i++)
                {
                    if (array[i] != nullptr)
                    {
                        continue;
                    }
                    array[i] = p->Item;
                    getUser()->RefreshStats();
                    return;
                }
            }
        }

        for (int i = GameScene::getUser()->BeltIdx; i < array.size(); i++)
        {
            if (array[i] != nullptr)
            {
                continue;
            }
            array[i] = p->Item;
            getUser()->RefreshStats();
            return;
        }

        for (int i = 0; i < GameScene::getUser()->BeltIdx; i++)
        {
            if (array[i] != nullptr)
            {
                continue;
            }
            array[i] = p->Item;
            getUser()->RefreshStats();
            return;
        }
    }

    void GameScene::SplitItem1(S::SplitItem1 *p)
    {
        MirItemCell *cell;

        switch (p->Grid)
        {
            case MirGridType::Inventory:
                Client.MirControls.MirItemCell tempVar = InventoryDialog.GetCell(p.UniqueID);
                cell = (tempVar != nullptr) ? tempVar : BeltDialog->GetCell(p->UniqueID);
                break;
            case MirGridType::Storage:
                cell = StorageDialog->GetCell(p->UniqueID);
                break;
            default:
                return;
        }

        if (cell == nullptr)
        {
            return;
        }

        cell->setLocked(false);

        if (!p->Success)
        {
            return;
        }
        cell->getItem()->Count -= p->Count;
        getUser()->RefreshStats();
    }

    void GameScene::UseItem(S::UseItem *p)
    {
        Client.MirControls.MirItemCell tempVar = InventoryDialog.GetCell(p.UniqueID);
        MirItemCell *cell = (tempVar != nullptr) ? tempVar : BeltDialog->GetCell(p->UniqueID);

        if (cell == nullptr)
        {
            return;
        }

        cell->setLocked(false);

        if (!p->Success)
        {
            return;
        }
        if (cell->getItem()->Count > 1)
        {
            cell->getItem()->Count--;
        }
        else
        {
            cell->setItem(nullptr);
        }
        getUser()->RefreshStats();
    }

    void GameScene::DropItem(S::DropItem *p)
    {
        Client.MirControls.MirItemCell tempVar = InventoryDialog.GetCell(p.UniqueID);
        MirItemCell *cell = (tempVar != nullptr) ? tempVar : BeltDialog->GetCell(p->UniqueID);

        if (cell == nullptr)
        {
            return;
        }

        cell->setLocked(false);

        if (!p->Success)
        {
            return;
        }

        if (p->Count == cell->getItem()->Count)
        {
            cell->setItem(nullptr);
        }
        else
        {
            cell->getItem()->Count -= p->Count;
        }

        getUser()->RefreshStats();
    }

    void GameScene::MountUpdate(S::MountUpdate *p)
    {
        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            if (MapControl::Objects[i]->ObjectID != p->ObjectID)
            {
                continue;
            }

            PlayerObject *player = dynamic_cast<PlayerObject*>(MapControl::Objects[i]);
            if (player != nullptr)
            {
                player->MountUpdate(p);
            }
            break;
        }

        if (p->ObjectID != getUser()->ObjectID)
        {
            return;
        }

        CanRun = false;

        getUser()->RefreshStats();

        GameScene::Scene->MountDialog->RefreshDialog();
        GameScene::Scene->Redraw();
    }

    void GameScene::TransformUpdate(S::TransformUpdate *p)
    {
        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            if (MapControl::Objects[i]->ObjectID != p->ObjectID)
            {
                continue;
            }

            PlayerObject *player = dynamic_cast<PlayerObject*>(MapControl::Objects[i]);
            if (player != nullptr)
            {
                player->TransformType = p->TransformType;
            }
            break;
        }
    }

    void GameScene::FishingUpdate(S::FishingUpdate *p)
    {
        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            if (MapControl::Objects[i]->ObjectID != p->ObjectID)
            {
                continue;
            }

            PlayerObject *player = dynamic_cast<PlayerObject*>(MapControl::Objects[i]);
            if (player != nullptr)
            {
                player->FishingUpdate(p);

            }
            break;
        }

        if (p->ObjectID != getUser()->ObjectID)
        {
            return;
        }

        GameScene::Scene->FishingStatusDialog->ProgressPercent = p->ProgressPercent;
        GameScene::Scene->FishingStatusDialog->ChancePercent = p->ChancePercent;

        GameScene::Scene->FishingStatusDialog->ChanceLabel->setText(StringHelper::formatSimple("{0}%", GameScene::Scene->FishingStatusDialog->ChancePercent));

        if (p->Fishing)
        {
            GameScene::Scene->FishingStatusDialog->Show();
        }
        else
        {
            GameScene::Scene->FishingStatusDialog->Hide();
        }

        Redraw();
    }

    void GameScene::CompleteQuest(S::CompleteQuest *p)
    {
        getUser()->CompletedQuests = p->CompletedQuests;
    }

    void GameScene::ShareQuest(S::ShareQuest *p)
    {
        ClientQuestInfo *quest = GameScene::QuestInfoList.FirstOrDefault([&] (std::any e)
        {
            return e->Index == p->QuestIndex;
        });

        if (quest == nullptr)
        {
            return;
        }

        MirMessageBox *messageBox = new MirMessageBox(StringHelper::formatSimple("{0} would like to share a quest with you. Do you accept?", p->SharerName), MirMessageBoxButtons::YesNo);

        messageBox->YesButton->Click += [&] (o, e)
        {
            C::AcceptQuest *tempVar = new C::AcceptQuest();
            tempVar->NPCIndex = 0;
            tempVar->QuestIndex = quest->Index;
            Network::Enqueue(tempVar);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
        };

        messageBox->Show();

        delete messageBox;
    }

    void GameScene::ChangeQuest(S::ChangeQuest *p)
    {
        switch (p->QuestState)
        {
            case QuestState::Add:
                getUser()->CurrentQuests.push_back(p->Quest);

                for (auto quest : getUser()->CurrentQuests)
                {
                    BindQuest(quest);
                }
                if (Settings::TrackedQuests.Contains(p->Quest->Id))
                {
                    GameScene::Scene->QuestTrackingDialog->AddQuest(p->Quest, true);
                }

                if (p->TrackQuest)
                {
                    GameScene::Scene->QuestTrackingDialog->AddQuest(p->Quest);
                }

                break;
            case QuestState::Update:
                for (int i = 0; i < getUser()->CurrentQuests.size(); i++)
                {
                    if (getUser()->CurrentQuests[i]->Id != p->Quest->Id)
                    {
                        continue;
                    }

                    getUser()->CurrentQuests[i] = p->Quest;
                }

                for (auto quest : getUser()->CurrentQuests)
                {
                    BindQuest(quest);
                }

                break;
            case QuestState::Remove:

                for (int i = getUser()->CurrentQuests.size() - 1; i >= 0; i--)
                {
                    if (getUser()->CurrentQuests[i]->Id != p->Quest->Id)
                    {
                        continue;
                    }

                    getUser()->CurrentQuests.erase(getUser()->CurrentQuests.begin() + i);
                }

                GameScene::Scene->QuestTrackingDialog->RemoveQuest(p->Quest);

                break;
        }

        GameScene::Scene->QuestTrackingDialog->DisplayQuests();

        if (Scene->QuestListDialog->getVisible())
        {
            Scene->QuestListDialog->DisplayInfo();
        }

        if (Scene->QuestLogDialog->getVisible())
        {
            Scene->QuestLogDialog->DisplayQuests();
        }
    }

    void GameScene::PlayerUpdate(S::PlayerUpdate *p)
    {
        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            if (MapControl::Objects[i]->ObjectID != p->ObjectID)
            {
                continue;
            }

            PlayerObject *player = dynamic_cast<PlayerObject*>(MapControl::Objects[i]);
            if (player != nullptr)
            {
                player->Update(p);
            }
            return;
        }
    }

    void GameScene::PlayerInspect(S::PlayerInspect *p)
    {
        InspectDialog::Items = p->Equipment;

        InspectDialog->Name = p->Name;
        InspectDialog->GuildName = p->GuildName;
        InspectDialog->GuildRank = p->GuildRank;
        InspectDialog->Class = p->Class;
        InspectDialog->Gender = p->Gender;
        InspectDialog->Hair = p->Hair;
        InspectDialog->Level = p->Level;
        InspectDialog->LoverName = p->LoverName;

        InspectDialog->RefreshInferface();
        InspectDialog->Show();
    }

    void GameScene::LogOutSuccess(S::LogOutSuccess *p)
    {
        for (int i = 0; i <= 3; i++) //Fix for orbs sound
        {
            SoundManager::StopSound(20000 + 126 * 10 + 5 + i);
        }

        setUser(nullptr);
        if (Settings::Resolution != 1024)
        {
            CMain::SetResolution(1024, 768);
        }

        ActiveScene = new SelectScene(p->Characters);

        Dispose();
    }

    void GameScene::LogOutFailed(S::LogOutFailed *p)
    {
        setEnabled(true);
    }

    void GameScene::TimeOfDay(S::TimeOfDay *p)
    {
        Lights = p->Lights;
        switch (Lights)
        {
            case LightSetting::Day:
            case LightSetting::Normal:
                MiniMapDialog->LightSetting->setIndex(2093);
                break;
            case LightSetting::Dawn:
                MiniMapDialog->LightSetting->setIndex(2095);
                break;
            case LightSetting::Evening:
                MiniMapDialog->LightSetting->setIndex(2094);
                break;
            case LightSetting::Night:
                MiniMapDialog->LightSetting->setIndex(2092);
                break;
        }
    }

    void GameScene::ChangeAMode(S::ChangeAMode *p)
    {
        AMode = p->Mode;

        switch (p->Mode)
        {
            case AttackMode::Peace:
                ChatDialog->ReceiveChat(GameLanguage::AttackMode_Peace, ChatType::Hint);
                break;
            case AttackMode::Group:
                ChatDialog->ReceiveChat(GameLanguage::AttackMode_Group, ChatType::Hint);
                break;
            case AttackMode::Guild:
                ChatDialog->ReceiveChat(GameLanguage::AttackMode_Guild, ChatType::Hint);
                break;
            case AttackMode::EnemyGuild:
                ChatDialog->ReceiveChat(GameLanguage::AttackMode_EnemyGuild, ChatType::Hint);
                break;
            case AttackMode::RedBrown:
                ChatDialog->ReceiveChat(GameLanguage::AttackMode_RedBrown, ChatType::Hint);
                break;
            case AttackMode::All:
                ChatDialog->ReceiveChat(GameLanguage::AttackMode_All, ChatType::Hint);
                break;
        }
    }

    void GameScene::ChangePMode(S::ChangePMode *p)
    {
        PMode = p->Mode;
        switch (p->Mode)
        {
            case PetMode::Both:
                ChatDialog->ReceiveChat(GameLanguage::PetMode_Both, ChatType::Hint);
                break;
            case PetMode::MoveOnly:
                ChatDialog->ReceiveChat(GameLanguage::PetMode_MoveOnly, ChatType::Hint);
                break;
            case PetMode::AttackOnly:
                ChatDialog->ReceiveChat(GameLanguage::PetMode_AttackOnly, ChatType::Hint);
                break;
            case PetMode::None:
                ChatDialog->ReceiveChat(GameLanguage::PetMode_None, ChatType::Hint);
                break;
        }
    }

    void GameScene::ObjectItem(S::ObjectItem *p)
    {
        ItemObject *ob = new ItemObject(p->ObjectID);
        ob->Load(p);
        /*
        string[] Warnings = new string[] {"HeroNecklace","AdamantineNecklace","8TrigramWheel","HangMaWheel","BaekTaGlove","SpiritReformer","BokMaWheel","BoundlessRing","ThunderRing","TaeGukRing","OmaSpiritRing","NobleRing"};
        if (Warnings.Contains(p.Name))
        {
            ChatDialog.ReceiveChat(string.Format("{0} at {1}", p.Name, p.Location), ChatType.Hint);
        }
        */

        delete ob;
    }

    void GameScene::ObjectGold(S::ObjectGold *p)
    {
        ItemObject *ob = new ItemObject(p->ObjectID);
        ob->Load(p);

        delete ob;
    }

    void GameScene::GainedItem(S::GainedItem *p)
    {
        Bind(p->Item);
        AddItem(p->Item);
        getUser()->RefreshStats();

        OutputMessage(std::string::Format(GameLanguage::YouGained, p->Item->getFriendlyName()));
    }

    void GameScene::GainedQuestItem(S::GainedQuestItem *p)
    {
        Bind(p->Item);
        AddQuestItem(p->Item);
    }

    void GameScene::GainedGold(S::GainedGold *p)
    {
        if (p->Gold == 0)
        {
            return;
        }

        Gold += p->Gold;
        SoundManager::PlaySound(SoundList::Gold);
        OutputMessage(std::string::Format(GameLanguage::YouGained2, p->Gold, GameLanguage::Gold));
    }

    void GameScene::LoseGold(S::LoseGold *p)
    {
        Gold -= p->Gold;
        SoundManager::PlaySound(SoundList::Gold);
    }

    void GameScene::GainedCredit(S::GainedCredit *p)
    {
        if (p->Credit == 0)
        {
            return;
        }

        Credit += p->Credit;
        SoundManager::PlaySound(SoundList::Gold);
        OutputMessage(std::string::Format(GameLanguage::YouGained2, p->Credit, GameLanguage::Credit));
    }

    void GameScene::LoseCredit(S::LoseCredit *p)
    {
        Credit -= p->Credit;
        SoundManager::PlaySound(SoundList::Gold);
    }

    void GameScene::ObjectMonster(S::ObjectMonster *p)
    {
        MonsterObject *mob;
        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];
            if (ob->ObjectID == p->ObjectID)
            {
                mob = static_cast<MonsterObject*>(ob);
                mob->Load(p, true);
                return;
            }
        }
        mob = new MonsterObject(p->ObjectID);
        mob->Load(p);

        delete mob;
    }

    void GameScene::ObjectAttack(S::ObjectAttack *p)
    {
        if (p->ObjectID == getUser()->ObjectID)
        {
            return;
        }

        QueuedAction *action = nullptr;

        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];
            if (ob->ObjectID != p->ObjectID)
            {
                continue;
            }
            if (ob->getRace() == ObjectType::Player)
            {
                action = new QueuedAction(); //FAR Close up attack
                action->Action = MirAction::Attack1;
                action->Direction = p->Direction;
                action->Location = p->Location;
                action->Params = std::vector<std::any>();
            }
            else
            {
                switch (p->Type)
                {
                    default:
                    {
                            action = new QueuedAction();
                            action->Action = MirAction::Attack1;
                            action->Direction = p->Direction;
                            action->Location = p->Location;
                            action->Params = std::vector<std::any>();
                            break;
                    }
                    case 1:
                    {
                            action = new QueuedAction();
                            action->Action = MirAction::Attack2;
                            action->Direction = p->Direction;
                            action->Location = p->Location;
                            action->Params = std::vector<std::any>();
                            break;
                    }
                    case 2:
                    {
                            action = new QueuedAction();
                            action->Action = MirAction::Attack3;
                            action->Direction = p->Direction;
                            action->Location = p->Location;
                            action->Params = std::vector<std::any>();
                            break;
                    }
                    case 3:
                    {
                            action = new QueuedAction();
                            action->Action = MirAction::Attack4;
                            action->Direction = p->Direction;
                            action->Location = p->Location;
                            action->Params = std::vector<std::any>();
                            break;
                    }
                }
            }
            action->Params.push_back(p->Spell);
            action->Params.push_back(p->Level);
            ob->ActionFeed.push_back(action);

//C# TO C++ CONVERTER TODO TASK: A 'delete action' statement was not added since action was passed to a method or constructor. Handle memory management manually.
            return;
        }

//C# TO C++ CONVERTER TODO TASK: A 'delete action' statement was not added since action was passed to a method or constructor. Handle memory management manually.
    }

    void GameScene::Struck(S::Struck *p)
    {
        LogTime = CMain::Time + Globals::LogDelay;

        NextRunTime = CMain::Time + 2500;
        getUser()->BlizzardStopTime = 0;
        getUser()->ClearMagic();
        if (getUser()->ReincarnationStopTime > CMain::Time)
        {
            Network::Enqueue(new C::CancelReincarnation {});
        }

        MirDirection dir = getUser()->Direction;
        Point *location = getUser()->CurrentLocation;

        for (int i = 0; i < getUser()->ActionFeed.size(); i++)
        {
            if (getUser()->ActionFeed[i]->Action == MirAction::Struck)
            {
                return;
            }
        }


        if (getUser()->ActionFeed.size() > 0)
        {
            dir = getUser()->ActionFeed[getUser()->ActionFeed.size() - 1]->Direction;
            location = getUser()->ActionFeed[getUser()->ActionFeed.size() - 1]->Location;
        }

        if (getUser()->Buffs.Any([&] (std::any a)
        {
            return a == BuffType::EnergyShield;
        }))
        {
            for (int j = 0; j < getUser()->Effects.size(); j++)
            {
                BuffEffect *effect = nullptr;
                effect = dynamic_cast<BuffEffect*>(getUser()->Effects[j]);

                if (effect != nullptr && effect->BuffType == BuffType::EnergyShield)
                {
                    effect->Clear();
                    effect->Remove();

                    BuffEffect *tempVar = new BuffEffect(Libraries::Magic2, 1890, 6, 600, getUser(), true, BuffType::EnergyShield);
                    tempVar->Repeat = false;
                    getUser()->Effects.push_back(effect = tempVar);
                    SoundManager::PlaySound(20000 + static_cast<unsigned short>(Spell::EnergyShield) * 10 + 1);

                    effect->Complete->addListener([&] (o, e)
                    {
                        BuffEffect *tempVar2 = new BuffEffect(Libraries::Magic2, 1900, 2, 800, getUser(), true, BuffType::EnergyShield);
                        tempVar2->Repeat = true;
                        getUser()->Effects.push_back(tempVar2);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar2' statement was not added since tempVar2 was passed to a method or constructor. Handle memory management manually.
                    });


//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
                    break;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
                }
            }
        }

        QueuedAction *action = new QueuedAction();
        action->Action = MirAction::Struck;
        action->Direction = dir;
        action->Location = location;
        action->Params = std::vector<std::any>();
        action->Params.push_back(p->AttackerID);
        getUser()->ActionFeed.push_back(action);

//C# TO C++ CONVERTER TODO TASK: A 'delete action' statement was not added since action was passed to a method or constructor. Handle memory management manually.
    }

    void GameScene::ObjectStruck(S::ObjectStruck *p)
    {
        if (p->ObjectID == getUser()->ObjectID)
        {
            return;
        }

        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];
            if (ob->ObjectID != p->ObjectID)
            {
                continue;
            }

            if (ob->SkipFrames)
            {
                return;
            }
            if (ob->ActionFeed.size() > 0 && ob->ActionFeed[ob->ActionFeed.size() - 1]->Action == MirAction::Struck)
            {
                return;
            }

            if (ob->getRace() == ObjectType::Player)
            {
                (static_cast<PlayerObject*>(ob))->BlizzardStopTime = 0;
            }
            QueuedAction *action = new QueuedAction();
            action->Action = MirAction::Struck;
            action->Direction = p->Direction;
            action->Location = p->Location;
            action->Params = std::vector<std::any>();
            action->Params.push_back(p->AttackerID);
            ob->ActionFeed.push_back(action);

            if (ob->Buffs.Any([&] (std::any a)
            {
                return a == BuffType::EnergyShield;
            }))
            {
                for (int j = 0; j < ob->Effects.size(); j++)
                {
                    BuffEffect *effect = nullptr;
                    effect = dynamic_cast<BuffEffect*>(ob->Effects[j]);

                    if (effect != nullptr && effect->BuffType == BuffType::EnergyShield)
                    {
                        effect->Clear();
                        effect->Remove();

                        BuffEffect *tempVar = new BuffEffect(Libraries::Magic2, 1890, 6, 600, ob, true, BuffType::EnergyShield);
                        tempVar->Repeat = false;
                        ob->Effects.push_back(effect = tempVar);
                        SoundManager::PlaySound(20000 + static_cast<unsigned short>(Spell::EnergyShield) * 10 + 1);

                        effect->Complete->addListener([&] (o, e)
                        {
                            BuffEffect *tempVar2 = new BuffEffect(Libraries::Magic2, 1900, 2, 800, ob, true, BuffType::EnergyShield);
                            tempVar2->Repeat = true;
                            ob->Effects.push_back(tempVar2);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar2' statement was not added since tempVar2 was passed to a method or constructor. Handle memory management manually.
                        });

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
                        break;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
                    }
                }
            }

//C# TO C++ CONVERTER TODO TASK: A 'delete action' statement was not added since action was passed to a method or constructor. Handle memory management manually.
            return;
        }
    }

    void GameScene::DamageIndicator(S::DamageIndicator *p)
    {
        if (Settings::DisplayDamage)
        {
            for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
            {
                MapObject *obj = MapControl::Objects[i];
                if (obj->ObjectID != p->ObjectID)
                {
                    continue;
                }

                if (obj->Damages.size() >= 10)
                {
                    return;
                }

                switch (p->Type)
                {
                    case DamageType::Hit: //add damage level colours
//C# TO C++ CONVERTER TODO TASK: There is no C++ equivalent to 'ToString':
                        Damage tempVar(p->Damage.ToString("#,##0"), 1000, obj->getRace() == ObjectType::Player ? Color::Red : Color::White, 50);
                        obj->Damages.push_back(&tempVar);
                        break;
                    case DamageType::Miss:
                        Damage tempVar2("Miss", 1200, obj->getRace() == ObjectType::Player ? Color::LightCoral : Color::LightGray, 50);
                        obj->Damages.push_back(&tempVar2);
                        break;
                    case DamageType::Critical:
                        Damage *tempVar3 = new Damage("Crit", 1000, obj->getRace() == ObjectType::Player ? Color::DarkRed : Color::DarkRed, 50);
                        tempVar3->Offset = 15;
                        obj->Damages.push_back(tempVar3);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                        break;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                }
            }
        }
    }

    void GameScene::DuraChanged(S::DuraChanged *p)
    {
        UserItem *item = nullptr;
        for (int i = 0; i < getUser()->Inventory.size(); i++)
        {
            if (getUser()->Inventory[i] != nullptr && getUser()->Inventory[i]->UniqueID == p->UniqueID)
            {
                item = getUser()->Inventory[i];
                break;
            }
        }


        if (item == nullptr)
        {
            for (int i = 0; i < getUser()->Equipment.size(); i++)
            {
                if (getUser()->Equipment[i] != nullptr && getUser()->Equipment[i]->UniqueID == p->UniqueID)
                {
                    item = getUser()->Equipment[i];
                    break;
                }
                if (getUser()->Equipment[i] != nullptr && !getUser()->Equipment[i]->Slots.empty())
                {
                    for (int j = 0; j < getUser()->Equipment[i]->Slots.size(); j++)
                    {
                        if (getUser()->Equipment[i]->Slots[j] != nullptr && getUser()->Equipment[i]->Slots[j]->UniqueID == p->UniqueID)
                        {
                            item = getUser()->Equipment[i]->Slots[j];
                            break;
                        }
                    }

                    if (item != nullptr)
                    {
                        break;
                    }
                }
            }
        }

        if (item == nullptr)
        {
            return;
        }

        item->CurrentDura = p->CurrentDura;

        if (item->CurrentDura == 0)
        {
            getUser()->RefreshStats();
            switch (item->Info->Type)
            {
                case ItemType::Mount:
                    ChatDialog->ReceiveChat(StringHelper::formatSimple("{0} is no longer loyal to you.", item->Info->getFriendlyName()), ChatType::System);
                    break;
                default:
                    ChatDialog->ReceiveChat(StringHelper::formatSimple("{0}'s dura has dropped to 0.", item->Info->getFriendlyName()), ChatType::System);
                    break;
            }

        }

        if (HoverItem == item)
        {
            DisposeItemLabel();
            CreateItemLabel(item);
        }

        CharacterDuraPanel->UpdateCharacterDura(item);
    }

    void GameScene::HealthChanged(S::HealthChanged *p)
    {
        getUser()->HP = p->HP;
        getUser()->MP = p->MP;

        getUser()->PercentHealth = static_cast<unsigned char>(getUser()->HP / static_cast<float>(getUser()->Stats[Stat::HP]) * 100);
    }

    void GameScene::DeleteQuestItem(S::DeleteQuestItem *p)
    {
        for (int i = 0; i < getUser()->QuestInventory.size(); i++)
        {
            UserItem *item = getUser()->QuestInventory[i];

            if (item == nullptr || item->UniqueID != p->UniqueID)
            {
                continue;
            }

            if (item->Count == p->Count)
            {
                getUser()->QuestInventory[i] = nullptr;
            }
            else
            {
                item->Count -= p->Count;
            }
            break;
        }
    }

    void GameScene::DeleteItem(S::DeleteItem *p)
    {
        for (int i = 0; i < getUser()->Inventory.size(); i++)
        {
            UserItem *item = getUser()->Inventory[i];

            if (item == nullptr || item->UniqueID != p->UniqueID)
            {
                continue;
            }

            if (item->Count == p->Count)
            {
                getUser()->Inventory[i] = nullptr;
            }
            else
            {
                item->Count -= p->Count;
            }
            break;
        }

        for (int i = 0; i < getUser()->Equipment.size(); i++)
        {
            UserItem *item = getUser()->Equipment[i];

            if (item != nullptr && item->Slots.size() > 0)
            {
                for (int j = 0; j < item->Slots.size(); j++)
                {
                    UserItem *slotItem = item->Slots[j];

                    if (slotItem == nullptr || slotItem->UniqueID != p->UniqueID)
                    {
                        continue;
                    }

                    if (slotItem->Count == p->Count)
                    {
                        item->Slots[j] = nullptr;
                    }
                    else
                    {
                        slotItem->Count -= p->Count;
                    }
                    break;
                }
            }

            if (item == nullptr || item->UniqueID != p->UniqueID)
            {
                continue;
            }

            if (item->Count == p->Count)
            {
                getUser()->Equipment[i] = nullptr;
            }
            else
            {
                item->Count -= p->Count;
            }
            break;
        }
        for (int i = 0; i < Storage.size(); i++)
        {
            auto item = Storage[i];
            if (item == nullptr || item->UniqueID != p->UniqueID)
            {
                continue;
            }

            if (item->Count == p->Count)
            {
                Storage[i] = nullptr;
            }
            else
            {
                item->Count -= p->Count;
            }
            break;
        }
        getUser()->RefreshStats();
    }

    void GameScene::Death(S::Death *p)
    {
        getUser()->Dead = true;

        QueuedAction *tempVar = new QueuedAction();
        tempVar->Action = MirAction::Die;
        tempVar->Direction = p->Direction;
        tempVar->Location = p->Location;
        getUser()->ActionFeed.push_back(tempVar);
        ShowReviveMessage = true;

        LogTime = 0;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
    }

    void GameScene::ObjectDied(S::ObjectDied *p)
    {
        if (p->ObjectID == getUser()->ObjectID)
        {
            return;
        }

        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];
            if (ob->ObjectID != p->ObjectID)
            {
                continue;
            }

            switch (p->Type)
            {
                default:
                    QueuedAction *tempVar = new QueuedAction();
                    tempVar->Action = MirAction::Die;
                    tempVar->Direction = p->Direction;
                    tempVar->Location = p->Location;
                    ob->ActionFeed.push_back(tempVar);
                    ob->Dead = true;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
                    break;
                case 1:
                    Effect tempVar2(Libraries::Magic2, 690, 10, 1000, ob->CurrentLocation);
                    MapControl::Effects.push_back(&tempVar2);
                    ob->Remove();
                    break;
                case 2:
                    SoundManager::PlaySound(20000 + static_cast<unsigned short>(Spell::DarkBody) * 10 + 1);
                    Effect tempVar3(Libraries::Magic2, 2600, 10, 1200, ob->CurrentLocation);
                    MapControl::Effects.push_back(&tempVar3);
                    ob->Remove();
                    break;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
            }
            return;
        }
    }

    void GameScene::ColourChanged(S::ColourChanged *p)
    {
        getUser()->NameColour = p->NameColour;
    }

    void GameScene::ObjectColourChanged(S::ObjectColourChanged *p)
    {
        if (p->ObjectID == getUser()->ObjectID)
        {
            return;
        }

        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];
            if (ob->ObjectID != p->ObjectID)
            {
                continue;
            }
            ob->NameColour = p->NameColour;
            return;
        }
    }

    void GameScene::ObjectGuildNameChanged(S::ObjectGuildNameChanged *p)
    {
        if (p->ObjectID == getUser()->ObjectID)
        {
            return;
        }

        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];
            if (ob->ObjectID != p->ObjectID)
            {
                continue;
            }
            PlayerObject *obPlayer = static_cast<PlayerObject*>(ob);
            obPlayer->GuildName = p->GuildName;
            return;
        }
    }

    void GameScene::GainExperience(S::GainExperience *p)
    {
        OutputMessage(std::string::Format(GameLanguage::ExperienceGained, p->Amount));
        MapObject::User->Experience += p->Amount;
    }

    void GameScene::LevelChanged(S::LevelChanged *p)
    {
        getUser()->Level = p->Level;
        getUser()->Experience = p->Experience;
        getUser()->MaxExperience = p->MaxExperience;
        getUser()->RefreshStats();
        OutputMessage(GameLanguage::LevelUp);
        Effect tempVar(Libraries::Magic2, 1200, 20, 2000, getUser());
        getUser()->Effects.push_back(&tempVar);
        SoundManager::PlaySound(SoundList::LevelUp);
        ChatDialog->ReceiveChat(GameLanguage::LevelUp, ChatType::LevelUp);
    }

    void GameScene::ObjectLeveled(S::ObjectLeveled *p)
    {
        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];
            if (ob->ObjectID != p->ObjectID)
            {
                continue;
            }
            Effect tempVar(Libraries::Magic2, 1180, 16, 2500, ob);
            ob->Effects.push_back(&tempVar);
            SoundManager::PlaySound(SoundList::LevelUp);
            return;
        }
    }

    void GameScene::ObjectHarvest(S::ObjectHarvest *p)
    {
        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];
            if (ob->ObjectID != p->ObjectID)
            {
                continue;
            }
            QueuedAction *tempVar = new QueuedAction();
            tempVar->Action = MirAction::Harvest;
            tempVar->Direction = ob->Direction;
            tempVar->Location = ob->CurrentLocation;
            ob->ActionFeed.push_back(tempVar);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
            return;
        }
    }

    void GameScene::ObjectHarvested(S::ObjectHarvested *p)
    {
        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];
            if (ob->ObjectID != p->ObjectID)
            {
                continue;
            }
            QueuedAction *tempVar = new QueuedAction();
            tempVar->Action = MirAction::Skeleton;
            tempVar->Direction = ob->Direction;
            tempVar->Location = ob->CurrentLocation;
            ob->ActionFeed.push_back(tempVar);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
            return;
        }
    }

    void GameScene::ObjectNPC(S::ObjectNPC *p)
    {
        NPCObject *ob = new NPCObject(p->ObjectID);
        ob->Load(p);

        delete ob;
    }

    void GameScene::NPCResponse(S::NPCResponse *p)
    {
        NPCTime = 0;
        NPCDialog->NewText(p->Page);

        if (p->Page.size() > 0)
        {
            NPCDialog->Show();
        }
        else
        {
            NPCDialog->Hide();
        }

        NPCGoodsDialog->Hide();
        NPCSubGoodsDialog->Hide();
        NPCCraftGoodsDialog->Hide();
        NPCDropDialog->Hide();
        StorageDialog->Hide();
        NPCAwakeDialog->Hide();
        RefineDialog->Hide();
        StorageDialog->Hide();
        TrustMerchantDialog->Hide();
        QuestListDialog->Hide();
    }

    void GameScene::NPCUpdate(S::NPCUpdate *p)
    {
        GameScene::NPCID = p->NPCID; //Updates the client with the correct NPC ID if it's manually called from the client
    }

    void GameScene::NPCImageUpdate(S::NPCImageUpdate *p)
    {
        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];
            if (ob->ObjectID != p->ObjectID || ob->getRace() != ObjectType::Merchant)
            {
                continue;
            }

            NPCObject *npc = static_cast<NPCObject*>(ob);
            npc->Image = p->Image;
            npc->Colour = p->Colour;

            npc->LoadLibrary();
            return;
        }
    }

    void GameScene::DefaultNPC(S::DefaultNPC *p)
    {
        GameScene::DefaultNPCID = p->ObjectID; //Updates the client with the correct Default NPC ID
    }

    void GameScene::ObjectHide(S::ObjectHide *p)
    {
        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];
            if (ob->ObjectID != p->ObjectID)
            {
                continue;
            }
            QueuedAction *tempVar = new QueuedAction();
            tempVar->Action = MirAction::Hide;
            tempVar->Direction = ob->Direction;
            tempVar->Location = ob->CurrentLocation;
            ob->ActionFeed.push_back(tempVar);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
            return;
        }
    }

    void GameScene::ObjectShow(S::ObjectShow *p)
    {
        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];
            if (ob->ObjectID != p->ObjectID)
            {
                continue;
            }
            QueuedAction *tempVar = new QueuedAction();
            tempVar->Action = MirAction::Show;
            tempVar->Direction = ob->Direction;
            tempVar->Location = ob->CurrentLocation;
            ob->ActionFeed.push_back(tempVar);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
            return;
        }
    }

    void GameScene::Poisoned(S::Poisoned *p)
    {
        auto previousPoisons = getUser()->Poison;

        getUser()->Poison = p->Poison;
        if (p->Poison::HasFlag(PoisonType::Stun) || p->Poison::HasFlag(PoisonType::Dazed) || p->Poison::HasFlag(PoisonType::Frozen) || p->Poison::HasFlag(PoisonType::Paralysis) || p->Poison::HasFlag(PoisonType::LRParalysis))
        {
            getUser()->ClearMagic();
        }

        if (previousPoisons::HasFlag(PoisonType::Blindness) && !getUser()->Poison::HasFlag(PoisonType::Blindness))
        {
            getUser()->BlindCount = 0;
        }
    }

    void GameScene::ObjectPoisoned(S::ObjectPoisoned *p)
    {
        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];
            if (ob->ObjectID != p->ObjectID)
            {
                continue;
            }
            ob->Poison = p->Poison;
            return;
        }
    }

    void GameScene::MapChanged(S::MapChanged *p)
    {
        MapControl->FileName = FileSystem::combine(Settings::MapPath, p->FileName + ".map");
        MapControl->Title = p->Title;
        MapControl->MiniMap = p->MiniMap;
        MapControl->BigMap = p->BigMap;
        MapControl->Lights = p->Lights;
        MapControl->MapDarkLight = p->MapDarkLight;
        MapControl->Music = p->Music;
        MapControl->LoadMap();
        MapControl::NextAction = 0;

        getUser()->CurrentLocation = p->Location;
        getUser()->MapLocation = p->Location;
        MapControl->AddObject(getUser());

        getUser()->Direction = p->Direction;

        getUser()->QueuedAction = nullptr;
        getUser()->ActionFeed.clear();
        getUser()->ClearMagic();
        getUser()->SetAction();

        GameScene::CanRun = false;

        MapControl->FloorValid = false;
        MapControl::InputDelay = CMain::Time + 400;
    }

    void GameScene::ObjectTeleportOut(S::ObjectTeleportOut *p)
    {
        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];
            if (ob->ObjectID != p->ObjectID)
            {
                continue;
            }
            Effect *effect = nullptr;

            bool playDefaultSound = true;

            switch (p->Type)
            {
                case 1: //Yimoogi
                {
                        effect = new Effect(Libraries::Magic2, 1300, 10, 500, ob);

                        delete effect;
                        break;
                }
                case 2: //RedFoxman
                {
                        effect = new Effect(Libraries::Monsters[static_cast<unsigned short>(Monster::RedFoxman)], 243, 10, 500, ob);

                        delete effect;
                        break;
                }
                case 4: //MutatedManWorm
                {
                        effect = new Effect(Libraries::Monsters[static_cast<unsigned short>(Monster::MutatedManworm)], 272, 6, 500, ob);

                        SoundManager::PlaySound((static_cast<unsigned short>(Monster::MutatedManworm)) * 10 + 7);
                        playDefaultSound = false;

                        delete effect;
                        break;
                }
                case 5: //WitchDoctor
                {
                        effect = new Effect(Libraries::Monsters[static_cast<unsigned short>(Monster::WitchDoctor)], 328, 20, 1000, ob);
                        SoundManager::PlaySound((static_cast<unsigned short>(Monster::WitchDoctor)) * 10 + 7);
                        playDefaultSound = false;

                        delete effect;
                        break;
                }
                case 6: //TurtleKing
                {
                        effect = new Effect(Libraries::Monsters[static_cast<unsigned short>(Monster::TurtleKing)], 946, 10, 500, ob);

                        delete effect;
                        break;
                }
                case 7: //Mandrill
                {
                        effect = new Effect(Libraries::Monsters[static_cast<unsigned short>(Monster::Mandrill)], 280, 10, 1000, ob);

                        delete effect;
                        break;
                }
                default:
                {
                        effect = new Effect(Libraries::Magic, 250, 10, 500, ob);

                        delete effect;
                        break;
                }
            }

            if (effect != nullptr)
            {
                effect->Complete->addListener([&] (o, e)
                {
                    ob->Remove();
                });
                ob->Effects.push_back(effect);
            }

            if (playDefaultSound)
            {
                SoundManager::PlaySound(SoundList::Teleport);
            }

//C# TO C++ CONVERTER TODO TASK: A 'delete effect' statement was not added since effect was passed to a method or constructor. Handle memory management manually.
            return;
        }
    }

    void GameScene::ObjectTeleportIn(S::ObjectTeleportIn *p)
    {
        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];
            if (ob->ObjectID != p->ObjectID)
            {
                continue;
            }

            bool playDefaultSound = true;

            switch (p->Type)
            {
                case 1: //Yimoogi
                {
                        Effect tempVar(Libraries::Magic2, 1310, 10, 500, ob);
                        ob->Effects.push_back(&tempVar);
                        break;
                }
                case 2: //RedFoxman
                {
                        Effect tempVar2(Libraries::Monsters[static_cast<unsigned short>(Monster::RedFoxman)], 253, 10, 500, ob);
                        ob->Effects.push_back(&tempVar2);
                        break;
                }
                case 4: //MutatedManWorm
                {
                        Effect tempVar3(Libraries::Monsters[static_cast<unsigned short>(Monster::MutatedManworm)], 278, 7, 500, ob);
                        ob->Effects.push_back(&tempVar3);

                        SoundManager::PlaySound((static_cast<unsigned short>(Monster::MutatedManworm)) * 10 + 7);
                        playDefaultSound = false;
                        break;
                }
                case 5: //WitchDoctor
                {
                        Effect tempVar4(Libraries::Monsters[static_cast<unsigned short>(Monster::WitchDoctor)], 348, 20, 1000, ob);
                        ob->Effects.push_back(&tempVar4);
                        SoundManager::PlaySound((static_cast<unsigned short>(Monster::WitchDoctor)) * 10 + 7);
                        playDefaultSound = false;
                        break;
                }
                case 6: //TurtleKing
                {
                        Effect tempVar5(Libraries::Monsters[static_cast<unsigned short>(Monster::TurtleKing)], 956, 10, 500, ob);
                        ob->Effects.push_back(&tempVar5);
                        break;
                }
                case 7: //Mandrill
                {
                        Effect tempVar6(Libraries::Monsters[static_cast<unsigned short>(Monster::Mandrill)], 290, 10, 1000, ob);
                        ob->Effects.push_back(&tempVar6);
                        break;
                }
                default:
                {
                        Effect tempVar7(Libraries::Magic, 260, 10, 500, ob);
                        ob->Effects.push_back(&tempVar7);
                        break;
                }
            }

            if (playDefaultSound)
            {
                SoundManager::PlaySound(SoundList::Teleport);
            }

            return;
        }


    }

    void GameScene::TeleportIn()
    {
        Effect tempVar(Libraries::Magic, 260, 10, 500, getUser());
        getUser()->Effects.push_back(&tempVar);
        SoundManager::PlaySound(SoundList::Teleport);
    }

    void GameScene::NPCGoods(S::NPCGoods *p)
    {
        for (int i = 0; i < p->List.size(); i++)
        {
            p->List[i]->Info = GetInfo(p->List[i]->ItemIndex);
        }

        NPCRate = p->Rate;
        HideAddedStoreStats = p->HideAddedStats;

        if (!NPCDialog->getVisible())
        {
            return;
        }

        switch (p->Type)
        {
            case PanelType::Buy:
                NPCGoodsDialog->UsePearls = false;
                NPCGoodsDialog->NewGoods(p->List);
                NPCGoodsDialog->Show();
                break;
            case PanelType::BuySub:
                NPCSubGoodsDialog->UsePearls = false;
                NPCSubGoodsDialog->NewGoods(p->List);
                NPCSubGoodsDialog->Show();
                break;
            case PanelType::Craft:
                NPCCraftGoodsDialog->UsePearls = false;
                NPCCraftGoodsDialog->NewGoods(p->List);
                NPCCraftGoodsDialog->Show();
                CraftDialog->Show();
                break;
        }
    }

    void GameScene::NPCPearlGoods(S::NPCPearlGoods *p)
    {
        for (int i = 0; i < p->List.size(); i++)
        {
            p->List[i]->Info = GetInfo(p->List[i]->ItemIndex);
        }

        NPCRate = p->Rate;

        if (!NPCDialog->getVisible())
        {
            return;
        }

        NPCGoodsDialog->UsePearls = true;
        NPCGoodsDialog->NewGoods(p->List);
        NPCGoodsDialog->Show();
    }

    void GameScene::NPCSell()
    {
        if (!NPCDialog->getVisible())
        {
            return;
        }
        NPCDropDialog->PType = PanelType::Sell;
        NPCDropDialog->Show();
    }

    void GameScene::NPCRepair(S::NPCRepair *p)
    {
        NPCRate = p->Rate;
        if (!NPCDialog->getVisible())
        {
            return;
        }
        NPCDropDialog->PType = PanelType::Repair;
        NPCDropDialog->Show();
    }

    void GameScene::NPCStorage()
    {
        if (NPCDialog->getVisible())
        {
            StorageDialog->Show();
        }
    }

    void GameScene::NPCRequestInput(S::NPCRequestInput *p)
    {
        MirInputBox *inputBox = new MirInputBox("Please enter the required information.");

        inputBox->OKButton->Click += [&] (o1, e1)
        {
            C::NPCConfirmInput *tempVar = new C::NPCConfirmInput();
            tempVar->Value = inputBox->InputTextBox->getText();
            tempVar->NPCID = p->NPCID;
            tempVar->PageName = p->PageName;
            Network::Enqueue(tempVar);
            inputBox->Dispose();

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
        };
        inputBox->Show();

        delete inputBox;
    }

    void GameScene::NPCSRepair(S::NPCSRepair *p)
    {
        NPCRate = p->Rate;
        if (!NPCDialog->getVisible())
        {
            return;
        }
        NPCDropDialog->PType = PanelType::SpecialRepair;
        NPCDropDialog->Show();
    }

    void GameScene::NPCRefine(S::NPCRefine *p)
    {
        NPCRate = p->Rate;
        if (!NPCDialog->getVisible())
        {
            return;
        }
        NPCDropDialog->PType = PanelType::Refine;
        if (p->Refining)
        {
            NPCDropDialog->Hide();
            NPCDialog->Hide();
        }
        else
        {
            NPCDropDialog->Show();
        }
    }

    void GameScene::NPCCheckRefine(S::NPCCheckRefine *p)
    {
        if (!NPCDialog->getVisible())
        {
            return;
        }
        NPCDropDialog->PType = PanelType::CheckRefine;
        NPCDropDialog->Show();
    }

    void GameScene::NPCCollectRefine(S::NPCCollectRefine *p)
    {
        if (!NPCDialog->getVisible())
        {
            return;
        }
        NPCDialog->Hide();
    }

    void GameScene::NPCReplaceWedRing(S::NPCReplaceWedRing *p)
    {
        if (!NPCDialog->getVisible())
        {
            return;
        }
        NPCRate = p->Rate;
        NPCDropDialog->PType = PanelType::ReplaceWedRing;
        NPCDropDialog->Show();
    }

    void GameScene::SellItem(S::SellItem *p)
    {
        Client.MirControls.MirItemCell tempVar = InventoryDialog.GetCell(p.UniqueID);
        MirItemCell *cell = (tempVar != nullptr) ? tempVar : BeltDialog->GetCell(p->UniqueID);

        if (cell == nullptr)
        {
            return;
        }

        cell->setLocked(false);

        if (!p->Success)
        {
            return;
        }

        if (p->Count == cell->getItem()->Count)
        {
            cell->setItem(nullptr);
        }
        else
        {
            cell->getItem()->Count -= p->Count;
        }

        getUser()->RefreshStats();
    }

    void GameScene::RepairItem(S::RepairItem *p)
    {
        Client.MirControls.MirItemCell tempVar = InventoryDialog.GetCell(p.UniqueID);
        MirItemCell *cell = (tempVar != nullptr) ? tempVar : BeltDialog->GetCell(p->UniqueID);

        if (cell == nullptr)
        {
            return;
        }

        cell->setLocked(false);
    }

    void GameScene::CraftItem(S::CraftItem *p)
    {
        if (!p->Success)
        {
            return;
        }

        CraftDialog->UpdateCraftCells();
        getUser()->RefreshStats();
    }

    void GameScene::ItemRepaired(S::ItemRepaired *p)
    {
        UserItem *item = nullptr;
        for (int i = 0; i < getUser()->Inventory.size(); i++)
        {
            if (getUser()->Inventory[i] != nullptr && getUser()->Inventory[i]->UniqueID == p->UniqueID)
            {
                item = getUser()->Inventory[i];
                break;
            }
        }

        if (item == nullptr)
        {
            for (int i = 0; i < getUser()->Equipment.size(); i++)
            {
                if (getUser()->Equipment[i] != nullptr && getUser()->Equipment[i]->UniqueID == p->UniqueID)
                {
                    item = getUser()->Equipment[i];
                    break;
                }
            }
        }

        if (item == nullptr)
        {
            return;
        }

        item->MaxDura = p->MaxDura;
        item->CurrentDura = p->CurrentDura;

        if (HoverItem == item)
        {
            DisposeItemLabel();
            CreateItemLabel(item);
        }
    }

    void GameScene::ItemSlotSizeChanged(S::ItemSlotSizeChanged *p)
    {
        UserItem *item = nullptr;
        for (int i = 0; i < getUser()->Inventory.size(); i++)
        {
            if (getUser()->Inventory[i] != nullptr && getUser()->Inventory[i]->UniqueID == p->UniqueID)
            {
                item = getUser()->Inventory[i];
                break;
            }
        }

        if (item == nullptr)
        {
            for (int i = 0; i < getUser()->Equipment.size(); i++)
            {
                if (getUser()->Equipment[i] != nullptr && getUser()->Equipment[i]->UniqueID == p->UniqueID)
                {
                    item = getUser()->Equipment[i];
                    break;
                }
            }
        }

        if (item == nullptr)
        {
            return;
        }

        item->SetSlotSize(std::make_optional(p->SlotSize));
    }

    void GameScene::ItemUpgraded(S::ItemUpgraded *p)
    {
        UserItem *item = nullptr;
        for (int i = 0; i < getUser()->Inventory.size(); i++)
        {
            if (getUser()->Inventory[i] != nullptr && getUser()->Inventory[i]->UniqueID == p->Item->UniqueID)
            {
                item = getUser()->Inventory[i];
                break;
            }
        }

        if (item == nullptr)
        {
            return;
        }

        item->AddedStats->Clear();
        item->AddedStats->Add(p->Item->AddedStats);

        item->MaxDura = p->Item->MaxDura;
        item->RefineAdded = p->Item->RefineAdded;

        GameScene::Scene->InventoryDialog->DisplayItemGridEffect(item->UniqueID, 0);

        if (HoverItem == item)
        {
            DisposeItemLabel();
            CreateItemLabel(item);
        }
    }

    void GameScene::NewMagic(S::NewMagic *p)
    {
        ClientMagic *magic = p->Magic;

        getUser()->Magics.push_back(magic);
        getUser()->RefreshStats();
        for (auto Bar : SkillBarDialogs)
        {
            Bar->Update();
        }
    }

    void GameScene::RemoveMagic(S::RemoveMagic *p)
    {
        getUser()->Magics.erase(getUser()->Magics.begin() + p->PlaceId);
        getUser()->RefreshStats();
        for (auto Bar : SkillBarDialogs)
        {
            Bar->Update();
        }
    }

    void GameScene::MagicLeveled(S::MagicLeveled *p)
    {
        for (int i = 0; i < getUser()->Magics.size(); i++)
        {
            ClientMagic *magic = getUser()->Magics[i];
            if (magic->Spell != p->Spell)
            {
                continue;
            }

            if (magic->Level != p->Level)
            {
                magic->Level = p->Level;
                getUser()->RefreshStats();
            }

            magic->Experience = p->Experience;
            break;
        }


    }

    void GameScene::Magic(S::Magic *p)
    {
        getUser()->Spell = p->Spell;
        getUser()->Cast = p->Cast;
        getUser()->TargetID = p->TargetID;
        getUser()->TargetPoint = p->Target;
        getUser()->SpellLevel = p->Level;
        getUser()->SecondaryTargetIDs = p->SecondaryTargetIDs;

        if (!p->Cast)
        {
            return;
        }

        ClientMagic *magic = getUser()->GetMagic(p->Spell);
        magic->CastTime = CMain::Time;
    }

    void GameScene::MagicDelay(S::MagicDelay *p)
    {
        ClientMagic *magic = getUser()->GetMagic(p->Spell);
        magic->Delay = p->Delay;
    }

    void GameScene::MagicCast(S::MagicCast *p)
    {
        ClientMagic *magic = getUser()->GetMagic(p->Spell);
        magic->CastTime = CMain::Time;
    }

    void GameScene::ObjectMagic(S::ObjectMagic *p)
    {
        if (p->SelfBroadcast == false && p->ObjectID == getUser()->ObjectID)
        {
            return;
        }

        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];
            if (ob->ObjectID != p->ObjectID)
            {
                continue;
            }

            QueuedAction *action = new QueuedAction();
            action->Action = MirAction::Spell;
            action->Direction = p->Direction;
            action->Location = p->Location;
            action->Params = std::vector<std::any>();
            action->Params.push_back(p->Spell);
            action->Params.push_back(p->TargetID);
            action->Params.push_back(p->Target);
            action->Params.push_back(p->Cast);
            action->Params.push_back(p->Level);
            action->Params.push_back(p->SecondaryTargetIDs);

            ob->ActionFeed.push_back(action);

//C# TO C++ CONVERTER TODO TASK: A 'delete action' statement was not added since action was passed to a method or constructor. Handle memory management manually.
            return;
        }
    }

    void GameScene::ObjectProjectile(S::ObjectProjectile *p)
    {
        MapObject *source = MapControl::GetObject(p->Source);

        if (source == nullptr)
        {
            return;
        }

        switch (p->Spell)
        {
            case Spell::FireBounce:
            {
                    SoundManager::PlaySound(20000 + static_cast<unsigned short>(Spell::GreatFireBall) * 10 + 1);

                    Missile *missile = source->CreateProjectile(410, Libraries::Magic, true, 6, 30, 4, 6, true, std::nullopt, p->Destination);

                    if (missile->Target != nullptr)
                    {
                        missile->Complete->addListener([&] (o, e)
                        {
                            auto sender = static_cast<Missile*>(o);
    
                            if (sender->Target->CurrentAction == MirAction::Dead)
                            {
                                return;
                            }
                            Effect tempVar(Libraries::Magic, 570, 10, 600, sender->Target);
                            sender->Target->Effects.push_back(&tempVar);
                            SoundManager::PlaySound(20000 + static_cast<unsigned short>(Spell::GreatFireBall) * 10 + 2);
                        });
                    }
            }
                break;
        }
    }

    void GameScene::ObjectEffect(S::ObjectEffect *p)
    {
        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];
            if (ob->ObjectID != p->ObjectID)
            {
                continue;
            }
            PlayerObject *player;
            MonsterObject *monster;

            switch (p->Effect)
            {
                case SpellEffect::FatalSword:
                    Effect tempVar(Libraries::Magic2, 1940, 4, 400, ob);
                    ob->Effects.push_back(&tempVar);
                    SoundManager::PlaySound(20000 + static_cast<unsigned short>(Spell::FatalSword) * 10);
                    break;
                case SpellEffect::StormEscape:
                    Effect tempVar2(Libraries::Magic3, 610, 10, 600, ob);
                    ob->Effects.push_back(&tempVar2);
                    SoundManager::PlaySound(SoundList::Teleport);
                    break;
                case SpellEffect::Teleport:
                    Effect tempVar3(Libraries::Magic, 1600, 10, 600, ob);
                    ob->Effects.push_back(&tempVar3);
                    SoundManager::PlaySound(SoundList::Teleport);
                    break;
                case SpellEffect::Healing:
                    SoundManager::PlaySound(20000 + static_cast<unsigned short>(Spell::Healing) * 10 + 1);
                    Effect tempVar4(Libraries::Magic, 370, 10, 800, ob);
                    ob->Effects.push_back(&tempVar4);
                    break;
                case SpellEffect::RedMoonEvil:
                    Effect *tempVar5 = new Effect(Libraries::Monsters[static_cast<unsigned short>(Monster::RedMoonEvil)], 32, 6, 400, ob);
                    tempVar5->Blend = false;
                    ob->Effects.push_back(tempVar5);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar5' statement was not added since tempVar5 was passed to a method or constructor. Handle memory management manually.
                    break;
                case SpellEffect::TwinDrakeBlade:
                    Effect tempVar6(Libraries::Magic2, 380, 6, 800, ob);
                    ob->Effects.push_back(&tempVar6);
                    break;
               case SpellEffect::MPEater:
                    for (int j = MapControl::Objects.size() - 1; j >= 0; j--)
                    {
                        MapObject *ob2 = MapControl::Objects[j];
                        if (ob2->ObjectID == p->EffectType)
                        {
                            Effect tempVar7(Libraries::Magic2, 2411, 19, 1900, ob2);
                            ob2->Effects.push_back(&tempVar7);
                            break;
                        }
                    }
                    Effect tempVar8(Libraries::Magic2, 2400, 9, 900, ob);
                    ob->Effects.push_back(&tempVar8);
                    SoundManager::PlaySound(20000 + static_cast<unsigned short>(Spell::FatalSword) * 10);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar5' statement was not added since tempVar5 was passed to a method or constructor. Handle memory management manually.
                    break;
                case SpellEffect::Bleeding:
                    Effect tempVar9(Libraries::Magic3, 60, 3, 400, ob);
                    ob->Effects.push_back(&tempVar9);
                    break;
                case SpellEffect::Hemorrhage:
                    SoundManager::PlaySound(20000 + static_cast<unsigned short>(Spell::Hemorrhage) * 10);
                    Effect tempVar10(Libraries::Magic3, 0, 4, 400, ob);
                    ob->Effects.push_back(&tempVar10);
                    Effect tempVar11(Libraries::Magic3, 28, 6, 600, ob);
                    ob->Effects.push_back(&tempVar11);
                    Effect tempVar12(Libraries::Magic3, 46, 8, 800, ob);
                    ob->Effects.push_back(&tempVar12);
                    break;
                case SpellEffect::MagicShieldUp:
                    if (ob->getRace() != ObjectType::Player)
                    {
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar5' statement was not added since tempVar5 was passed to a method or constructor. Handle memory management manually.
                        return;
                    }
                    player = static_cast<PlayerObject*>(ob);
                    if (player->ShieldEffect != nullptr)
                    {
                        player->ShieldEffect->Clear();
                        player->ShieldEffect->Remove();
                    }
                    player->MagicShield = true;
                    Effect *tempVar13 = new Effect(Libraries::Magic, 3890, 3, 600, ob);
                    tempVar13->Repeat = true;
                    player->Effects.push_back(player->ShieldEffect = tempVar13);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar13' statement was not added since tempVar13 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar5' statement was not added since tempVar5 was passed to a method or constructor. Handle memory management manually.
                    break;
                case SpellEffect::MagicShieldDown:
                    if (ob->getRace() != ObjectType::Player)
                    {
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar13' statement was not added since tempVar13 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar5' statement was not added since tempVar5 was passed to a method or constructor. Handle memory management manually.
                        return;
                    }
                    player = static_cast<PlayerObject*>(ob);
                    if (player->ShieldEffect != nullptr)
                    {
                        player->ShieldEffect->Clear();
                        player->ShieldEffect->Remove();
                    }
                    player->ShieldEffect = nullptr;
                    player->MagicShield = false;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar13' statement was not added since tempVar13 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar5' statement was not added since tempVar5 was passed to a method or constructor. Handle memory management manually.
                    break;
                case SpellEffect::GreatFoxSpirit:
                    Effect tempVar14(Libraries::Monsters[static_cast<unsigned short>(Monster::GreatFoxSpirit)], 375 + (CMain::Random->Next(3) * 20), 20, 1400, ob);
                    ob->Effects.push_back(&tempVar14);
                    SoundManager::PlaySound((static_cast<unsigned short>(Monster::GreatFoxSpirit) * 10) + 5);
                    break;
                case SpellEffect::Entrapment:
                    Effect tempVar15(Libraries::Magic2, 1010, 10, 1500, ob);
                    ob->Effects.push_back(&tempVar15);
                    Effect tempVar16(Libraries::Magic2, 1020, 8, 1200, ob);
                    ob->Effects.push_back(&tempVar16);
                    break;
                case SpellEffect::Critical:
                    //ob.Effects.Add(new Effect(Libraries.CustomEffects, 0, 12, 60, ob));
                    break;
                case SpellEffect::Reflect:
                    Effect tempVar17(Libraries::Effect, 580, 10, 70, ob);
                    ob->Effects.push_back(&tempVar17);
                    break;
                case SpellEffect::ElementalBarrierUp:
                    if (ob->getRace() != ObjectType::Player)
                    {
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar13' statement was not added since tempVar13 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar5' statement was not added since tempVar5 was passed to a method or constructor. Handle memory management manually.
                        return;
                    }
                    player = static_cast<PlayerObject*>(ob);
                    if (player->ElementalBarrierEffect != nullptr)
                    {
                        player->ElementalBarrierEffect->Clear();
                        player->ElementalBarrierEffect->Remove();
                    }

                    player->ElementalBarrier = true;
                    Effect *tempVar18 = new Effect(Libraries::Magic3, 1890, 10, 2000, ob);
                    tempVar18->Repeat = true;
                    player->Effects.push_back(player->ElementalBarrierEffect = tempVar18);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar18' statement was not added since tempVar18 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar13' statement was not added since tempVar13 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar5' statement was not added since tempVar5 was passed to a method or constructor. Handle memory management manually.
                    break;
                case SpellEffect::ElementalBarrierDown:
                    if (ob->getRace() != ObjectType::Player)
                    {
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar18' statement was not added since tempVar18 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar13' statement was not added since tempVar13 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar5' statement was not added since tempVar5 was passed to a method or constructor. Handle memory management manually.
                        return;
                    }
                    player = static_cast<PlayerObject*>(ob);
                    if (player->ElementalBarrierEffect != nullptr)
                    {
                        player->ElementalBarrierEffect->Clear();
                        player->ElementalBarrierEffect->Remove();
                    }
                    player->ElementalBarrierEffect = nullptr;
                    player->ElementalBarrier = false;
                    Effect tempVar19(Libraries::Magic3, 1910, 7, 1400, ob);
                    player->Effects.push_back(player->ElementalBarrierEffect = &tempVar19);
                    SoundManager::PlaySound(20000 + 131 * 10 + 5);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar18' statement was not added since tempVar18 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar13' statement was not added since tempVar13 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar5' statement was not added since tempVar5 was passed to a method or constructor. Handle memory management manually.
                    break;
                case SpellEffect::DelayedExplosion:
                {
                    int effectid = DelayedExplosionEffect::GetOwnerEffectID(ob->ObjectID);
                    if (effectid < 0)
                    {
                        DelayedExplosionEffect tempVar20(Libraries::Magic3, 1590, 8, 1200, ob, true, 0, 0);
                        ob->Effects.push_back(&tempVar20);
                    }
                    else if (effectid >= 0)
                    {
                        if (DelayedExplosionEffect::effectlist[effectid]->stage < p->EffectType)
                        {
                            DelayedExplosionEffect::effectlist[effectid]->Remove();
                            DelayedExplosionEffect tempVar21(Libraries::Magic3, 1590 + (static_cast<int>(p->EffectType) * 10), 8, 1200, ob, true, static_cast<int>(p->EffectType), 0);
                            ob->Effects.push_back(&tempVar21);
                        }
                    }

                    //else
                    //    ob.Effects.Add(new DelayedExplosionEffect(Libraries.Magic3, 1590 + ((int)p.EffectType * 10), 8, 1200, ob, true, (int)p.EffectType, 0));

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar18' statement was not added since tempVar18 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar13' statement was not added since tempVar13 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar5' statement was not added since tempVar5 was passed to a method or constructor. Handle memory management manually.
                    break;
                }
                case SpellEffect::AwakeningSuccess:
                {
                        Effect *ef = new Effect(Libraries::Magic3, 900, 16, 1600, ob, CMain::Time + p->DelayTime);
                        ef->Played->addListener([&] (o, e)
                        {
                            SoundManager::PlaySound(50002);
                        });
                        ef->Complete->addListener([&] (o, e)
                        {
                            MapControl->setAwakeningAction(false);
                        });
                        ob->Effects.push_back(ef);
                        Effect *tempVar22 = new Effect(Libraries::Magic3, 840, 16, 1600, ob, CMain::Time + p->DelayTime);
                        tempVar22->Blend = false;
                        ob->Effects.push_back(tempVar22);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar22' statement was not added since tempVar22 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete ef' statement was not added since ef was passed to a method or constructor. Handle memory management manually.
                }

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar18' statement was not added since tempVar18 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar13' statement was not added since tempVar13 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar5' statement was not added since tempVar5 was passed to a method or constructor. Handle memory management manually.
                    break;
                case SpellEffect::AwakeningFail:
                {
                        Effect *ef = new Effect(Libraries::Magic3, 920, 9, 900, ob, CMain::Time + p->DelayTime);
                        ef->Played->addListener([&] (o, e)
                        {
                            SoundManager::PlaySound(50003);
                        });
                        ef->Complete->addListener([&] (o, e)
                        {
                            MapControl->setAwakeningAction(false);
                        });
                        ob->Effects.push_back(ef);
                        Effect *tempVar23 = new Effect(Libraries::Magic3, 860, 9, 900, ob, CMain::Time + p->DelayTime);
                        tempVar23->Blend = false;
                        ob->Effects.push_back(tempVar23);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar23' statement was not added since tempVar23 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete ef' statement was not added since ef was passed to a method or constructor. Handle memory management manually.
                }

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar18' statement was not added since tempVar18 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar13' statement was not added since tempVar13 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar5' statement was not added since tempVar5 was passed to a method or constructor. Handle memory management manually.
                    break;
                case SpellEffect::AwakeningHit:
                {
                        Effect *ef = new Effect(Libraries::Magic3, 880, 5, 500, ob, CMain::Time + p->DelayTime);
                        ef->Played->addListener([&] (o, e)
                        {
                            SoundManager::PlaySound(50001);
                        });
                        ob->Effects.push_back(ef);
                        Effect *tempVar24 = new Effect(Libraries::Magic3, 820, 5, 500, ob, CMain::Time + p->DelayTime);
                        tempVar24->Blend = false;
                        ob->Effects.push_back(tempVar24);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar24' statement was not added since tempVar24 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete ef' statement was not added since ef was passed to a method or constructor. Handle memory management manually.
                }

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar18' statement was not added since tempVar18 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar13' statement was not added since tempVar13 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar5' statement was not added since tempVar5 was passed to a method or constructor. Handle memory management manually.
                    break;
                case SpellEffect::AwakeningMiss:
                {
                        Effect *ef = new Effect(Libraries::Magic3, 890, 5, 500, ob, CMain::Time + p->DelayTime);
                        ef->Played->addListener([&] (o, e)
                        {
                            SoundManager::PlaySound(50000);
                        });
                        ob->Effects.push_back(ef);
                        Effect *tempVar25 = new Effect(Libraries::Magic3, 830, 5, 500, ob, CMain::Time + p->DelayTime);
                        tempVar25->Blend = false;
                        ob->Effects.push_back(tempVar25);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar25' statement was not added since tempVar25 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete ef' statement was not added since ef was passed to a method or constructor. Handle memory management manually.
                }

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar18' statement was not added since tempVar18 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar13' statement was not added since tempVar13 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar5' statement was not added since tempVar5 was passed to a method or constructor. Handle memory management manually.
                    break;
                case SpellEffect::TurtleKing:
                {
                        Effect *ef = new Effect(Libraries::Monsters[static_cast<unsigned short>(Monster::TurtleKing)], CMain::Random->Next(2) == 0 ? 922 : 934, 12, 1200, ob);
                        ef->Played->addListener([&] (o, e)
                        {
                            SoundManager::PlaySound(20000 + static_cast<unsigned short>(Spell::HellFire) * 10 + 1);
                        });
                        ob->Effects.push_back(ef);

//C# TO C++ CONVERTER TODO TASK: A 'delete ef' statement was not added since ef was passed to a method or constructor. Handle memory management manually.
                }

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar18' statement was not added since tempVar18 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar13' statement was not added since tempVar13 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar5' statement was not added since tempVar5 was passed to a method or constructor. Handle memory management manually.
                    break;
                case SpellEffect::Behemoth:
                {
                        Effect tempVar26(Libraries::Monsters[static_cast<unsigned short>(Monster::Behemoth)], 788, 10, 1500, ob->CurrentLocation);
                        MapControl::Effects.push_back(&tempVar26);
                        Effect *tempVar27 = new Effect(Libraries::Monsters[static_cast<unsigned short>(Monster::Behemoth)], 778, 10, 1500, ob->CurrentLocation, 0, true);
                        tempVar27->Blend = false;
                        MapControl::Effects.push_back(tempVar27);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar27' statement was not added since tempVar27 was passed to a method or constructor. Handle memory management manually.
                }

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar18' statement was not added since tempVar18 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar13' statement was not added since tempVar13 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar5' statement was not added since tempVar5 was passed to a method or constructor. Handle memory management manually.
                    break;
                case SpellEffect::Stunned:
                    Effect *tempVar28 = new Effect(Libraries::Monsters[static_cast<unsigned short>(Monster::StoningStatue)], 632, 10, 1000, ob);
                    tempVar28->Repeat = p->Time > 0;
                    tempVar28->RepeatUntil = p->Time > 0 ? CMain::Time + p->Time : 0;
                    ob->Effects.push_back(tempVar28);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar28' statement was not added since tempVar28 was passed to a method or constructor. Handle memory management manually.
                    break;
                case SpellEffect::IcePillar:
                    Effect tempVar29(Libraries::Monsters[static_cast<unsigned short>(Monster::IcePillar)], 18, 8, 800, ob);
                    ob->Effects.push_back(&tempVar29);
                    break;
                case SpellEffect::KingGuard:
                    Effect *tempVar30 = new Effect(Libraries::Monsters[static_cast<unsigned short>(Monster::KingGuard)], 753, 10, 1000, ob);
                    tempVar30->Blend = false;
                    ob->Effects.push_back(tempVar30);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar30' statement was not added since tempVar30 was passed to a method or constructor. Handle memory management manually.
                    break;
                case SpellEffect::KingGuard2:
                    Effect *tempVar31 = new Effect(Libraries::Monsters[static_cast<unsigned short>(Monster::KingGuard)], 763, 10, 1000, ob);
                    tempVar31->Blend = false;
                    ob->Effects.push_back(tempVar31);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar31' statement was not added since tempVar31 was passed to a method or constructor. Handle memory management manually.
                    break;
                case SpellEffect::MonsterMACBuff: //loop - look @ MagicShield for start / loop / end
                    BuffEffect *tempVar32 = new BuffEffect(Libraries::Monsters[static_cast<unsigned short>(Monster::HornedArcher)], 477, 10, 1000, ob, true, BuffType::MonsterMACBuff);
                    tempVar32->Repeat = true;
                    ob->Effects.push_back(tempVar32);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar32' statement was not added since tempVar32 was passed to a method or constructor. Handle memory management manually.
                    break;

                case SpellEffect::DeathCrawlerBreath:
                    Effect *tempVar33 = new Effect(Libraries::Monsters[static_cast<unsigned short>(Monster::DeathCrawler)], 272 + (static_cast<int>(ob->Direction) * 4), 4, 400, ob);
                    tempVar33->Blend = true;
                    ob->Effects.push_back(tempVar33);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar33' statement was not added since tempVar33 was passed to a method or constructor. Handle memory management manually.
                    break;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar33' statement was not added since tempVar33 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar32' statement was not added since tempVar32 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar31' statement was not added since tempVar31 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar30' statement was not added since tempVar30 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar28' statement was not added since tempVar28 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar18' statement was not added since tempVar18 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar13' statement was not added since tempVar13 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar5' statement was not added since tempVar5 was passed to a method or constructor. Handle memory management manually.
            }

            return;
        }
    }

    void GameScene::RangeAttack(S::RangeAttack *p)
    {
        getUser()->TargetID = p->TargetID;
        getUser()->TargetPoint = p->Target;
        getUser()->Spell = p->Spell;
    }

    void GameScene::Pushed(S::Pushed *p)
    {
        QueuedAction *tempVar = new QueuedAction();
        tempVar->Action = MirAction::Pushed;
        tempVar->Direction = p->Direction;
        tempVar->Location = p->Location;
        getUser()->ActionFeed.push_back(tempVar);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
    }

    void GameScene::ObjectPushed(S::ObjectPushed *p)
    {
        if (p->ObjectID == getUser()->ObjectID)
        {
            return;
        }

        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];
            if (ob->ObjectID != p->ObjectID)
            {
                continue;
            }
            QueuedAction *tempVar = new QueuedAction();
            tempVar->Action = MirAction::Pushed;
            tempVar->Direction = p->Direction;
            tempVar->Location = p->Location;
            ob->ActionFeed.push_back(tempVar);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
            return;
        }
    }

    void GameScene::ObjectName(S::ObjectName *p)
    {
        if (p->ObjectID == getUser()->ObjectID)
        {
            return;
        }

        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];
            if (ob->ObjectID != p->ObjectID)
            {
                continue;
            }
            ob->Name = p->Name;
            return;
        }
    }

    void GameScene::UserStorage(S::UserStorage *p)
    {
        if (Storage.size() != p->Storage.size())
        {
            Array::Resize(Storage, p->Storage.size());
        }

        Storage = p->Storage;

        for (int i = 0; i < Storage.size(); i++)
        {
            if (Storage[i] == nullptr)
            {
                continue;
            }
            Bind(Storage[i]);
        }
    }

    void GameScene::SwitchGroup(S::SwitchGroup *p)
    {
        GroupDialog::AllowGroup = p->AllowGroup;
    }

    void GameScene::DeleteGroup()
    {
        GroupDialog::GroupList.clear();
        ChatDialog->ReceiveChat("You have left the group.", ChatType::Group);
    }

    void GameScene::DeleteMember(S::DeleteMember *p)
    {
        GroupDialog::GroupList.Remove(p->Name);
        ChatDialog->ReceiveChat(StringHelper::formatSimple("-{0} has left the group.", p->Name), ChatType::Group);
    }

    void GameScene::GroupInvite(S::GroupInvite *p)
    {
        MirMessageBox *messageBox = new MirMessageBox(StringHelper::formatSimple("Do you want to group with {0}?", p->Name), MirMessageBoxButtons::YesNo);

        messageBox->YesButton->Click += [&] (o, e)
        {
            C::GroupInvite *tempVar = new C::GroupInvite();
            tempVar->AcceptInvite = true;
            Network::Enqueue(tempVar);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
        };
        messageBox->NoButton->Click += [&] (o, e)
        {
            C::GroupInvite *tempVar2 = new C::GroupInvite();
            tempVar2->AcceptInvite = false;
            Network::Enqueue(tempVar2);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar2' statement was not added since tempVar2 was passed to a method or constructor. Handle memory management manually.
        };

        messageBox->Show();

        delete messageBox;
    }

    void GameScene::AddMember(S::AddMember *p)
    {
        GroupDialog::GroupList.push_back(p->Name);
        ChatDialog->ReceiveChat(StringHelper::formatSimple("-{0} has joined the group.", p->Name), ChatType::Group);
    }

    void GameScene::Revived()
    {
        getUser()->SetAction();
        getUser()->Dead = false;
        Effect tempVar(Libraries::Magic2, 1220, 20, 2000, getUser());
        getUser()->Effects.push_back(&tempVar);
        SoundManager::PlaySound(SoundList::Revive);
    }

    void GameScene::ObjectRevived(S::ObjectRevived *p)
    {
        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];
            if (ob->ObjectID != p->ObjectID)
            {
                continue;
            }
            if (p->Effect)
            {
                Effect tempVar(Libraries::Magic2, 1220, 20, 2000, ob);
                ob->Effects.push_back(&tempVar);
                SoundManager::PlaySound(SoundList::Revive);
            }
            ob->Dead = false;
            ob->ActionFeed.clear();
            QueuedAction *tempVar2 = new QueuedAction();
            tempVar2->Action = MirAction::Revive;
            tempVar2->Direction = ob->Direction;
            tempVar2->Location = ob->CurrentLocation;
            ob->ActionFeed.push_back(tempVar2);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar2' statement was not added since tempVar2 was passed to a method or constructor. Handle memory management manually.
            return;
        }
    }

    void GameScene::SpellToggle(S::SpellToggle *p)
    {
        switch (p->Spell)
        {
            //Warrior
            case Spell::Slaying:
                Slaying = p->CanUse;
                break;
            case Spell::Thrusting:
                Thrusting = p->CanUse;
                ChatDialog->ReceiveChat(Thrusting ? "Use Thrusting." : "Do not use Thrusting.", ChatType::Hint);
                break;
            case Spell::HalfMoon:
                HalfMoon = p->CanUse;
                ChatDialog->ReceiveChat(HalfMoon ? "Use HalfMoon." : "Do not use HalfMoon.", ChatType::Hint);
                break;
            case Spell::CrossHalfMoon:
                CrossHalfMoon = p->CanUse;
                ChatDialog->ReceiveChat(CrossHalfMoon ? "Use CrossHalfMoon." : "Do not use CrossHalfMoon.", ChatType::Hint);
                break;
            case Spell::DoubleSlash:
                DoubleSlash = p->CanUse;
                ChatDialog->ReceiveChat(DoubleSlash ? "Use DoubleSlash." : "Do not use DoubleSlash.", ChatType::Hint);
                break;
            case Spell::FlamingSword:
                FlamingSword = p->CanUse;
                if (FlamingSword)
                {
                    ChatDialog->ReceiveChat(GameLanguage::WeaponSpiritFire, ChatType::Hint);
                }
                else
                {
                    ChatDialog->ReceiveChat(GameLanguage::SpiritsFireDisappeared, ChatType::System);
                }
                break;
        }
    }

    void GameScene::ObjectHealth(S::ObjectHealth *p)
    {
        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];
            if (ob->ObjectID != p->ObjectID)
            {
                continue;
            }
            ob->PercentHealth = p->Percent;
            ob->HealthTime = CMain::Time + p->Expire * 1000;
            return;
        }
    }

    void GameScene::MapEffect(S::MapEffect *p)
    {
        switch (p->Effect)
        {
            case SpellEffect::Mine:
            {
                SoundManager::PlaySound(10091);
                Effect *HitWall = new Effect(Libraries::Effect, 8 * p->Value, 3, 240, p->Location);
                HitWall->Light = 0;
                MapControl::Effects.push_back(HitWall);
                break;

//C# TO C++ CONVERTER TODO TASK: A 'delete HitWall' statement was not added since HitWall was passed to a method or constructor. Handle memory management manually.
            }
            case SpellEffect::Tester:
            {
                Effect *eff = new Effect(Libraries::Effect, 328, 10, 500, p->Location);
                eff->Light = 0;
                MapControl::Effects.push_back(eff);
                break;

//C# TO C++ CONVERTER TODO TASK: A 'delete eff' statement was not added since eff was passed to a method or constructor. Handle memory management manually.
            }
        }
    }

    void GameScene::ObjectRangeAttack(S::ObjectRangeAttack *p)
    {
        if (p->ObjectID == getUser()->ObjectID)
        {
            return;
        }

        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];
            if (ob->ObjectID != p->ObjectID)
            {
                continue;
            }
            QueuedAction *action = nullptr;
            if (ob->getRace() == ObjectType::Player)
            {
                switch (p->Type)
                {
                    default:
                    {
                            action = new QueuedAction();
                            action->Action = MirAction::AttackRange1;
                            action->Direction = p->Direction;
                            action->Location = p->Location;
                            action->Params = std::vector<std::any>();

                            delete action;
                            break;
                    }
                }
            }
            else
            {
                switch (p->Type)
                {
                    case 1:
                    {
                            action = new QueuedAction();
                            action->Action = MirAction::AttackRange2;
                            action->Direction = p->Direction;
                            action->Location = p->Location;
                            action->Params = std::vector<std::any>();

                            delete action;
                            break;
                    }
                    case 2:
                    {
                            action = new QueuedAction();
                            action->Action = MirAction::AttackRange3;
                            action->Direction = p->Direction;
                            action->Location = p->Location;
                            action->Params = std::vector<std::any>();

                            delete action;
                            break;
                    }
                    default:
                    {
                            action = new QueuedAction();
                            action->Action = MirAction::AttackRange1;
                            action->Direction = p->Direction;
                            action->Location = p->Location;
                            action->Params = std::vector<std::any>();

                            delete action;
                            break;
                    }
                }
            }
            action->Params.push_back(p->TargetID);
            action->Params.push_back(p->Target);
            action->Params.push_back(p->Spell);
            action->Params.push_back(std::vector<unsigned int>());

            ob->ActionFeed.push_back(action);

//C# TO C++ CONVERTER TODO TASK: A 'delete action' statement was not added since action was passed to a method or constructor. Handle memory management manually.
            return;
        }
    }

    void GameScene::AddBuff(S::AddBuff *p)
    {
        ClientBuff *buff = p->Buff;

        buff->ExpireTime += CMain::Time;

        if (buff->ObjectID == getUser()->ObjectID)
        {
            for (int i = 0; i < Buffs.size(); i++)
            {
                if (Buffs[i]->Type != buff->Type)
                {
                    continue;
                }

                Buffs[i] = buff;
                getUser()->RefreshStats();
                return;
            }

            Buffs.push_back(buff);
            BuffsDialog->CreateBuff(buff);
            getUser()->RefreshStats();
        }

        if (!buff->Visible || buff->ObjectID <= 0)
        {
            return;
        }

        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];
            if (ob->ObjectID != buff->ObjectID)
            {
                continue;
            }
            if ((dynamic_cast<PlayerObject*>(ob) != nullptr) || (dynamic_cast<MonsterObject*>(ob) != nullptr))
            {
                if (!std::find(ob->Buffs.begin(), ob->Buffs.end(), buff->Type) != ob->Buffs.end())
                {
                    ob->Buffs.push_back(buff->Type);
                }

                ob->AddBuffEffect(buff->Type);
                return;
            }
        }
    }

    void GameScene::RemoveBuff(S::RemoveBuff *p)
    {
        for (int i = 0; i < Buffs.size(); i++)
        {
            if (Buffs[i]->Type != p->Type || getUser()->ObjectID != p->ObjectID)
            {
                continue;
            }

            switch (Buffs[i]->Type)
            {
                case BuffType::SwiftFeet:
                    getUser()->Sprint = false;
                    break;
                case BuffType::Transform:
                    getUser()->TransformType = -1;
                    break;
            }

            Buffs.erase(Buffs.begin() + i);
            BuffsDialog->RemoveBuff(i);
        }

        if (getUser()->ObjectID == p->ObjectID)
        {
            getUser()->RefreshStats();
        }

        if (p->ObjectID <= 0)
        {
            return;
        }

        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];

            if (ob->ObjectID != p->ObjectID)
            {
                continue;
            }

            ob->Buffs.Remove(p->Type);
            ob->RemoveBuffEffect(p->Type);
            return;
        }
    }

    void GameScene::ObjectHidden(S::ObjectHidden *p)
    {
        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];
            if (ob->ObjectID != p->ObjectID)
            {
                continue;
            }
            ob->Hidden = p->Hidden;
            return;
        }
    }

    void GameScene::ObjectSneaking(S::ObjectSneaking *p)
    {
        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];
            if (ob->ObjectID != p->ObjectID)
            {
                continue;
            }
           // ob.SneakingActive = p.SneakingActive;
            return;
        }
    }

    void GameScene::ObjectLevelEffects(S::ObjectLevelEffects *p)
    {
        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];
            if (ob->ObjectID != p->ObjectID || ob->getRace() != ObjectType::Player)
            {
                continue;
            }

            PlayerObject *temp = static_cast<PlayerObject*>(ob);

            temp->LevelEffects = p->LevelEffects;

            temp->SetEffects();
            return;
        }
    }

    void GameScene::RefreshItem(S::RefreshItem *p)
    {
        Bind(p->Item);

        if (SelectedCell != nullptr && SelectedCell->getItem()->UniqueID == p->Item->UniqueID)
        {
            SelectedCell = nullptr;
        }

        if (HoverItem != nullptr && HoverItem->UniqueID == p->Item->UniqueID)
        {
            DisposeItemLabel();
            CreateItemLabel(p->Item);
        }

        for (int i = 0; i < getUser()->Inventory.size(); i++)
        {
            if (getUser()->Inventory[i] != nullptr && getUser()->Inventory[i]->UniqueID == p->Item->UniqueID)
            {
                getUser()->Inventory[i] = p->Item;
                getUser()->RefreshStats();
                return;
            }
        }

        for (int i = 0; i < getUser()->Equipment.size(); i++)
        {
            if (getUser()->Equipment[i] != nullptr && getUser()->Equipment[i]->UniqueID == p->Item->UniqueID)
            {
                getUser()->Equipment[i] = p->Item;
                getUser()->RefreshStats();
                return;
            }
        }
    }

    void GameScene::ObjectSpell(S::ObjectSpell *p)
    {
        SpellObject *ob = new SpellObject(p->ObjectID);
        ob->Load(p);

        delete ob;
    }

    void GameScene::ObjectDeco(S::ObjectDeco *p)
    {
        DecoObject *ob = new DecoObject(p->ObjectID);
        ob->Load(p);

        delete ob;
    }

    void GameScene::UserDash(S::UserDash *p)
    {
        if (getUser()->Direction == p->Direction && getUser()->CurrentLocation == p->Location)
        {
            MapControl::NextAction = 0;
            return;
        }
        MirAction action = getUser()->CurrentAction == MirAction::DashL ? MirAction::DashR : MirAction::DashL;
        for (int i = getUser()->ActionFeed.size() - 1; i >= 0; i--)
        {
            if (getUser()->ActionFeed[i]->Action == MirAction::DashR)
            {
                action = MirAction::DashL;
                break;
            }
            if (getUser()->ActionFeed[i]->Action == MirAction::DashL)
            {
                action = MirAction::DashR;
                break;
            }
        }

        QueuedAction *tempVar = new QueuedAction();
        tempVar->Action = action;
        tempVar->Direction = p->Direction;
        tempVar->Location = p->Location;
        getUser()->ActionFeed.push_back(tempVar);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
    }

    void GameScene::UserDashFail(S::UserDashFail *p)
    {
        MapControl::NextAction = 0;
        QueuedAction *tempVar = new QueuedAction();
        tempVar->Action = MirAction::DashFail;
        tempVar->Direction = p->Direction;
        tempVar->Location = p->Location;
        getUser()->ActionFeed.push_back(tempVar);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
    }

    void GameScene::ObjectDash(S::ObjectDash *p)
    {
        if (p->ObjectID == getUser()->ObjectID)
        {
            return;
        }

        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];
            if (ob->ObjectID != p->ObjectID)
            {
                continue;
            }

            MirAction action = MirAction::DashL;

            if (ob->ActionFeed.size() > 0 && ob->ActionFeed[ob->ActionFeed.size() - 1]->Action == action)
            {
                action = MirAction::DashR;
            }

            QueuedAction *tempVar = new QueuedAction();
            tempVar->Action = action;
            tempVar->Direction = p->Direction;
            tempVar->Location = p->Location;
            ob->ActionFeed.push_back(tempVar);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
            return;
        }
    }

    void GameScene::ObjectDashFail(S::ObjectDashFail *p)
    {
        if (p->ObjectID == getUser()->ObjectID)
        {
            return;
        }

        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];
            if (ob->ObjectID != p->ObjectID)
            {
                continue;
            }

            QueuedAction *tempVar = new QueuedAction();
            tempVar->Action = MirAction::DashFail;
            tempVar->Direction = p->Direction;
            tempVar->Location = p->Location;
            ob->ActionFeed.push_back(tempVar);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
            return;
        }
    }

    void GameScene::UserBackStep(S::UserBackStep *p)
    {
        if (getUser()->Direction == p->Direction && getUser()->CurrentLocation == p->Location)
        {
            MapControl::NextAction = 0;
            return;
        }
        QueuedAction *tempVar = new QueuedAction();
        tempVar->Action = MirAction::Jump;
        tempVar->Direction = p->Direction;
        tempVar->Location = p->Location;
        getUser()->ActionFeed.push_back(tempVar);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
    }

    void GameScene::ObjectBackStep(S::ObjectBackStep *p)
    {
        if (p->ObjectID == getUser()->ObjectID)
        {
            return;
        }

        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];
            if (ob->ObjectID != p->ObjectID)
            {
                continue;
            }

            ob->JumpDistance = p->Distance;

            QueuedAction *tempVar = new QueuedAction();
            tempVar->Action = MirAction::Jump;
            tempVar->Direction = p->Direction;
            tempVar->Location = p->Location;
            ob->ActionFeed.push_back(tempVar);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
            return;
        }
    }

    void GameScene::UserDashAttack(S::UserDashAttack *p)
    {
        if (getUser()->Direction == p->Direction && getUser()->CurrentLocation == p->Location)
        {
            MapControl::NextAction = 0;
            return;
        }
        //User.JumpDistance = p.Distance;
        QueuedAction *tempVar = new QueuedAction();
        tempVar->Action = MirAction::DashAttack;
        tempVar->Direction = p->Direction;
        tempVar->Location = p->Location;
        getUser()->ActionFeed.push_back(tempVar);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
    }

    void GameScene::ObjectDashAttack(S::ObjectDashAttack *p)
    {
        if (p->ObjectID == getUser()->ObjectID)
        {
            return;
        }

        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];
            if (ob->ObjectID != p->ObjectID)
            {
                continue;
            }

            (static_cast<PlayerObject*>(ob))->JumpDistance = p->Distance;

            QueuedAction *tempVar = new QueuedAction();
            tempVar->Action = MirAction::DashAttack;
            tempVar->Direction = p->Direction;
            tempVar->Location = p->Location;
            ob->ActionFeed.push_back(tempVar);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
            return;
        }
    }

    void GameScene::UserAttackMove(S::UserAttackMove *p)
    {
        MapControl::NextAction = 0;
        if (getUser()->CurrentLocation == p->Location && getUser()->Direction == p->Direction)
        {
            return;
        }


        MapControl->RemoveObject(getUser());
        getUser()->CurrentLocation = p->Location;
        getUser()->MapLocation = p->Location;
        MapControl->AddObject(getUser());


        MapControl->FloorValid = false;
        MapControl::InputDelay = CMain::Time + 400;


        if (getUser()->Dead)
        {
            return;
        }


        getUser()->ClearMagic();
        getUser()->QueuedAction = nullptr;


        for (int i = getUser()->ActionFeed.size() - 1; i >= 0; i--)
        {
            if (getUser()->ActionFeed[i]->Action == MirAction::Pushed)
            {
                continue;
            }
            getUser()->ActionFeed.erase(getUser()->ActionFeed.begin() + i);
        }


        getUser()->SetAction();

        QueuedAction *tempVar = new QueuedAction();
        tempVar->Action = MirAction::Standing;
        tempVar->Direction = p->Direction;
        tempVar->Location = p->Location;
        getUser()->ActionFeed.push_back(tempVar);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
    }

    void GameScene::SetConcentration(S::SetConcentration *p)
    {
        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            if (MapControl::Objects[i]->getRace() != ObjectType::Player)
            {
                continue;
            }

            PlayerObject *ob = dynamic_cast<PlayerObject*>(MapControl::Objects[i]);
            if (ob->ObjectID != p->ObjectID)
            {
                continue;
            }

            ob->Concentrating = p->Enabled;
            ob->ConcentrateInterrupted = p->Interrupted;

            if (p->Enabled && !p->Interrupted)
            {
                int idx = InterruptionEffect::GetOwnerEffectID(ob->ObjectID);

                if (idx < 0)
                {
                    InterruptionEffect tempVar(Libraries::Magic3, 1860, 8, 8 * 100, ob, true);
                    ob->Effects.push_back(&tempVar);
                    SoundManager::PlaySound(20000 + 129 * 10);
                }
            }
            break;
        }
    }

    void GameScene::SetElemental(S::SetElemental *p)
    {
        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            if (MapControl::Objects[i]->getRace() != ObjectType::Player)
            {
                continue;
            }

            PlayerObject *ob = dynamic_cast<PlayerObject*>(MapControl::Objects[i]);
            if (ob->ObjectID != p->ObjectID)
            {
                continue;
            }

            ob->HasElements = p->Enabled;
            ob->ElementCasted = p->Casted && getUser()->ObjectID != p->ObjectID;
            ob->ElementsLevel = static_cast<int>(p->Value);
            int elementType = static_cast<int>(p->ElementType);
            int maxExp = static_cast<int>(p->ExpLast);

            if (p->Enabled && p->ElementType > 0)
            {
                ElementsEffect tempVar(Libraries::Magic3, 1630 + ((elementType - 1) * 10), 10, 10 * 100, ob, true, 1 + (elementType - 1), maxExp, getUser()->ObjectID == p->ObjectID && ((elementType == 4 || elementType == 3)));
                ob->Effects.push_back(&tempVar);
            }
        }
    }

    void GameScene::RemoveDelayedExplosion(S::RemoveDelayedExplosion *p)
    {
        //if (p.ObjectID == User.ObjectID) return;

        int effectid = DelayedExplosionEffect::GetOwnerEffectID(p->ObjectID);
        if (effectid >= 0)
        {
            DelayedExplosionEffect::effectlist[effectid]->Remove();
        }
    }

    void GameScene::SetBindingShot(S::SetBindingShot *p)
    {
        if (p->ObjectID == getUser()->ObjectID)
        {
            return;
        }

        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];
            if (ob->ObjectID != p->ObjectID)
            {
                continue;
            }
            if (ob->getRace() != ObjectType::Monster)
            {
                continue;
            }

            Effect tempVar(Libraries::MagicC, 0, 8, 700, ob);
            TrackableEffect *NetCast = new TrackableEffect(&tempVar);
            NetCast->EffectName = "BindingShotDrop";

            //TrackableEffect NetDropped = new TrackableEffect(new Effect(Libraries.ArcherMagic, 7, 1, 1000, ob, CMain.Time + 600) { Repeat = true, RepeatUntil = CMain.Time + (p.Value - 1500) });
            TrackableEffect *NetDropped = new TrackableEffect(new Effect(Libraries::MagicC, 7, 1, 1000, ob) {Repeat = true, RepeatUntil = CMain::Time + (p->Value - 1500)});
            NetDropped->EffectName = "BindingShotDown";

            Effect tempVar2(Libraries::MagicC, 8, 8, 700, ob);
            TrackableEffect *NetFall = new TrackableEffect(&tempVar2);
            NetFall->EffectName = "BindingShotFall";

            NetDropped->Complete->addListener([&] (o1, e1)
            {
                SoundManager::PlaySound(20000 + 130 * 10 + 6); //sound M130-6
                ob->Effects.push_back(NetFall);
            });
            NetCast->Complete->addListener([&] (o, e)
            {
                SoundManager::PlaySound(20000 + 130 * 10 + 5); //sound M130-5
                ob->Effects.push_back(NetDropped);
            });
            ob->Effects.push_back(NetCast);

//C# TO C++ CONVERTER TODO TASK: A 'delete NetFall' statement was not added since NetFall was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete NetDropped' statement was not added since NetDropped was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete NetCast' statement was not added since NetCast was passed to a method or constructor. Handle memory management manually.
            break;
        }
    }

    void GameScene::SendOutputMessage(S::SendOutputMessage *p)
    {
        OutputMessage(p->Message, p->Type);
    }

    void GameScene::NPCConsign()
    {
        if (!NPCDialog->getVisible())
        {
            return;
        }
        NPCDropDialog->PType = PanelType::Consign;
        NPCDropDialog->Show();
    }

    void GameScene::NPCMarket(S::NPCMarket *p)
    {
        for (int i = 0; i < p->Listings.size(); i++)
        {
            Bind(p->Listings[i]->Item);
        }

        TrustMerchantDialog->Show();
        TrustMerchantDialog::UserMode = p->UserMode;
        TrustMerchantDialog->Listings = p->Listings;
        TrustMerchantDialog->Page = 0;
        TrustMerchantDialog->PageCount = p->Pages;
        TrustMerchantDialog->UpdateInterface();
    }

    void GameScene::NPCMarketPage(S::NPCMarketPage *p)
    {
        if (!TrustMerchantDialog->getVisible())
        {
            return;
        }

        for (int i = 0; i < p->Listings.size(); i++)
        {
            Bind(p->Listings[i]->Item);
        }

        TrustMerchantDialog->Listings.insert(TrustMerchantDialog->Listings.end(), p->Listings.begin(), p->Listings.end());
        TrustMerchantDialog->Page = (TrustMerchantDialog->Listings.size() - 1) / 10;
        TrustMerchantDialog->UpdateInterface();
    }

    void GameScene::ConsignItem(S::ConsignItem *p)
    {
        Client.MirControls.MirItemCell tempVar = InventoryDialog.GetCell(p.UniqueID);
        MirItemCell *cell = (tempVar != nullptr) ? tempVar : BeltDialog->GetCell(p->UniqueID);

        if (cell == nullptr)
        {
            return;
        }

        cell->setLocked(false);

        if (!p->Success)
        {
            return;
        }

        cell->setItem(nullptr);

        getUser()->RefreshStats();
    }

    void GameScene::MarketFail(S::MarketFail *p)
    {
        TrustMerchantDialog::MarketTime = 0;
        switch (p->Reason)
        {
            case 0:
                MirMessageBox::Show("You cannot use the TrustMerchant when dead.");
                break;
            case 1:
                MirMessageBox::Show("You cannot buy from the TrustMerchant without using.");
                break;
            case 2:
                MirMessageBox::Show("This item has already been sold.");
                break;
            case 3:
                MirMessageBox::Show("This item has Expired and cannot be brought.");
                break;
            case 4:
                MirMessageBox::Show(GameLanguage::LowGold);
                break;
            case 5:
                MirMessageBox::Show("You do not have enough weight or space spare to buy this item.");
                break;
            case 6:
                MirMessageBox::Show("You cannot buy your own items.");
                break;
            case 7:
                MirMessageBox::Show("You are too far away from the Trust Merchant.");
                break;
            case 8:
                MirMessageBox::Show("You cannot hold enough gold to get your sale.");
                break;
            case 9:
                MirMessageBox::Show("This item has not met the minimum bid yet.");
                break;
            case 10:
                MirMessageBox::Show("Auction has already ended for this item.");
                break;
        }

    }

    void GameScene::MarketSuccess(S::MarketSuccess *p)
    {
        TrustMerchantDialog::MarketTime = 0;
        MirMessageBox::Show(p->Message);
    }

    void GameScene::ObjectSitDown(S::ObjectSitDown *p)
    {
        if (p->ObjectID == getUser()->ObjectID)
        {
            return;
        }

        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];
            if (ob->ObjectID != p->ObjectID)
            {
                continue;
            }
            if (ob->getRace() != ObjectType::Monster)
            {
                continue;
            }
            ob->SitDown = p->Sitting;
            QueuedAction *tempVar = new QueuedAction();
            tempVar->Action = MirAction::SitDown;
            tempVar->Direction = p->Direction;
            tempVar->Location = p->Location;
            ob->ActionFeed.push_back(tempVar);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
            return;
        }
    }

    void GameScene::BaseStatsInfo(S::BaseStatsInfo *p)
    {
        getUser()->CoreStats = p->Stats;
        getUser()->RefreshStats();
    }

    void GameScene::UserName(S::UserName *p)
    {
        for (int i = 0; i < UserIdList.size(); i++)
        {
            if (UserIdList[i]->Id == p->Id)
            {
                UserIdList[i]->UserName = p->Name;
                break;
            }
        }
        DisposeItemLabel();
        HoverItem = nullptr;
    }

    void GameScene::ChatItemStats(S::ChatItemStats *p)
    {
        //for (int i = 0; i < ChatItemList.Count; i++)
        //    if (ChatItemList[i].ID == p.ChatItemId)
        //    {
        //        ChatItemList[i].ItemStats = p.Stats;
        //        ChatItemList[i].RecievedTick = CMain.Time;
        //    }
    }

    void GameScene::GuildInvite(S::GuildInvite *p)
    {
        MirMessageBox *messageBox = new MirMessageBox(StringHelper::formatSimple("Do you want to join the {0} guild?", p->Name), MirMessageBoxButtons::YesNo);

        messageBox->YesButton->Click += [&] (o, e)
        {
            C::GuildInvite *tempVar = new C::GuildInvite();
            tempVar->AcceptInvite = true;
            Network::Enqueue(tempVar);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
        };
        messageBox->NoButton->Click += [&] (o, e)
        {
            C::GuildInvite *tempVar2 = new C::GuildInvite();
            tempVar2->AcceptInvite = false;
            Network::Enqueue(tempVar2);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar2' statement was not added since tempVar2 was passed to a method or constructor. Handle memory management manually.
        };

        messageBox->Show();

        delete messageBox;
    }

    void GameScene::GuildNameRequest(S::GuildNameRequest *p)
    {
        MirInputBox *inputBox = new MirInputBox("Please enter a guild name, length must be 3~20 characters.");
        inputBox->InputTextBox->TextBox->KeyPress += [&] (o, e)
        {
            std::string Allowed = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            if (!Allowed.find(e::KeyChar) != std::string::npos && e::KeyChar != static_cast<char>(Keys->Back))
            {
                e->Handled = true;
            }
        };
        inputBox->OKButton->Click += [&] (o, e)
        {
            if (inputBox->InputTextBox->getText().find('\\') != std::string::npos)
            {
                ChatDialog->ReceiveChat("You cannot use the \\ sign in a guildname!", ChatType::System);
                inputBox->InputTextBox->setText("");
            }
            C::GuildNameReturn *tempVar = new C::GuildNameReturn();
            tempVar->Name = inputBox->InputTextBox->getText();
            Network::Enqueue(tempVar);
            inputBox->Dispose();

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
        };
        inputBox->Show();

        delete inputBox;
    }

    void GameScene::GuildRequestWar(S::GuildRequestWar *p)
    {
        MirInputBox *inputBox = new MirInputBox("Please enter the guild you would like to go to war with.");

        inputBox->OKButton->Click += [&] (o, e)
        {
            C::GuildWarReturn *tempVar = new C::GuildWarReturn();
            tempVar->Name = inputBox->InputTextBox->getText();
            Network::Enqueue(tempVar);
            inputBox->Dispose();

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
        };
        inputBox->Show();

        delete inputBox;
    }

    void GameScene::GuildNoticeChange(S::GuildNoticeChange *p)
    {
        if (p->update == -1)
        {
            GuildDialog->NoticeChanged = true;
        }
        else
        {
            GuildDialog->NoticeChange(p->notice);
        }
    }

    void GameScene::GuildMemberChange(S::GuildMemberChange *p)
    {
        switch (p->Status)
        {
            case 0: // logged of
                GuildDialog->MemberStatusChange(p->Name, false);
                break;
            case 1: // logged on
                ChatDialog->ReceiveChat(StringHelper::formatSimple("{0} logged on.", p->Name), ChatType::Guild);
                GuildDialog->MemberStatusChange(p->Name, true);
                break;
            case 2: //new member
                ChatDialog->ReceiveChat(StringHelper::formatSimple("{0} joined guild.", p->Name), ChatType::Guild);
                GuildDialog->MemberCount++;
                GuildDialog->MembersChanged = true;
                break;
            case 3: //kicked member
                ChatDialog->ReceiveChat(StringHelper::formatSimple("{0} got removed from the guild.", p->Name), ChatType::Guild);
                GuildDialog->MembersChanged = true;
                break;
            case 4: //member left
                ChatDialog->ReceiveChat(StringHelper::formatSimple("{0} left the guild.", p->Name), ChatType::Guild);
                GuildDialog->MembersChanged = true;
                break;
            case 5: //rank change (name or different rank)
                GuildDialog->MembersChanged = true;
                break;
            case 6: //new rank
                if (p->Ranks.size() > 0)
                {
                    GuildDialog->NewRankRecieved(p->Ranks[0]);
                }
                break;
            case 7: //rank option changed
                if (p->Ranks.size() > 0)
                {
                    GuildDialog->RankChangeRecieved(p->Ranks[0]);
                }
                break;
            case 8: //my rank changed
                if (p->Ranks.size() > 0)
                {
                    GuildDialog->MyRankChanged(p->Ranks[0]);
                }
                break;
            case 255:
                GuildDialog->NewMembersList(p->Ranks);
                break;
        }
    }

    void GameScene::GuildStatus(S::GuildStatus *p)
    {
        if ((getUser()->GuildName == "") && (p->GuildName != ""))
        {
            GuildDialog->NoticeChanged = true;
            GuildDialog->MembersChanged = true;
        }
        if (p->GuildName == "")
        {
            GuildDialog->Hide();
        }

        if ((getUser()->GuildName == p->GuildName) && (GuildDialog->Level < p->Level))
        {
            //guild leveled
        }
        bool GuildChange = getUser()->GuildName != p->GuildName;
        getUser()->GuildName = p->GuildName;
        getUser()->GuildRankName = p->GuildRankName;
        GuildDialog->Level = p->Level;
        GuildDialog->Experience = p->Experience;
        GuildDialog->MaxExperience = p->MaxExperience;
        GuildDialog->Gold = p->Gold;
        GuildDialog->SparePoints = p->SparePoints;
        GuildDialog->MemberCount = p->MemberCount;
        GuildDialog->MaxMembers = p->MaxMembers;
        GuildDialog->Voting = p->Voting;
        GuildDialog->ItemCount = p->ItemCount;
        GuildDialog->BuffCount = p->BuffCount;
        GuildDialog->StatusChanged(p->MyOptions);
        GuildDialog::MyRankId = p->MyRankId;
        GuildDialog->UpdateMembers();
        //reset guildbuffs
        if (GuildChange)
        {
            GuildDialog->EnabledBuffs.clear();
            GuildDialog->UpdateActiveStats();
            S::RemoveBuff *tempVar = new S::RemoveBuff();
            tempVar->ObjectID = getUser()->ObjectID;
            tempVar->Type = BuffType::Guild;
            RemoveBuff(tempVar);
            getUser()->RefreshStats();

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
        }
    }

    void GameScene::GuildExpGain(S::GuildExpGain *p)
    {
        //OutputMessage(string.Format("Guild Experience Gained {0}.", p.Amount));
        GuildDialog->Experience += p->Amount;
    }

    void GameScene::GuildStorageGoldChange(S::GuildStorageGoldChange *p)
    {
        switch (p->Type)
        {
            case 0:
                ChatDialog->ReceiveChat(StringHelper::formatSimple("{0} donated {1} gold to guild funds.", p->Name, p->Amount), ChatType::Guild);
                GuildDialog->Gold += p->Amount;
                break;
            case 1:
                ChatDialog->ReceiveChat(StringHelper::formatSimple("{0} retrieved {1} gold from guild funds.", p->Name, p->Amount), ChatType::Guild);
                if (GuildDialog->Gold > p->Amount)
                {
                    GuildDialog->Gold -= p->Amount;
                }
                else
                {
                    GuildDialog->Gold = 0;
                }
                break;
            case 2:
                if (GuildDialog->Gold > p->Amount)
                {
                    GuildDialog->Gold -= p->Amount;
                }
                else
                {
                    GuildDialog->Gold = 0;
                }
                break;
            case 3:
                GuildDialog->Gold += p->Amount;
                break;
        }
    }

    void GameScene::GuildStorageItemChange(S::GuildStorageItemChange *p)
    {
        MirItemCell *fromCell = nullptr;
        MirItemCell *toCell = nullptr;
        switch (p->Type)
        {
            case 0: //store
                toCell = GuildDialog->StorageGrid[p->To];

                if (toCell == nullptr)
                {
                    return;
                }

                toCell->setLocked(false);
                toCell->setItem(p->Item->Item);
                Bind(toCell->getItem());
                if (p->User != getUser()->Id)
                {
                    return;
                }
                fromCell = p->From < getUser()->BeltIdx ? BeltDialog->Grid[p->From] : InventoryDialog->Grid[p->From - getUser()->BeltIdx];
                fromCell->setLocked(false);
                if (fromCell != nullptr)
                {
                    fromCell->setItem(nullptr);
                }
                getUser()->RefreshStats();
                break;
            case 1: //retrieve
                fromCell = GuildDialog->StorageGrid[p->From];

                if (fromCell == nullptr)
                {
                    return;
                }
                fromCell->setLocked(false);

                if (p->User != getUser()->Id)
                {
                    fromCell->setItem(nullptr);
                    return;
                }
                toCell = p->To < getUser()->BeltIdx ? BeltDialog->Grid[p->To] : InventoryDialog->Grid[p->To - getUser()->BeltIdx];
                if (toCell == nullptr)
                {
                    return;
                }
                toCell->setLocked(false);
                toCell->setItem(fromCell->getItem());
                fromCell->setItem(nullptr);
                break;

            case 2:
                toCell = GuildDialog->StorageGrid[p->To];
                fromCell = GuildDialog->StorageGrid[p->From];

                if (toCell == nullptr || fromCell == nullptr)
                {
                    return;
                }

                toCell->setLocked(false);
                fromCell->setLocked(false);
                fromCell->setItem(toCell->getItem());
                toCell->setItem(p->Item->Item);

                Bind(toCell->getItem());
                if (fromCell->getItem() != nullptr)
                {
                    Bind(fromCell->getItem());
                }
                break;
            case 3: //failstore
                fromCell = p->From < getUser()->BeltIdx ? BeltDialog->Grid[p->From] : InventoryDialog->Grid[p->From - getUser()->BeltIdx];
                toCell = GuildDialog->StorageGrid[p->To];

                if (toCell == nullptr || fromCell == nullptr)
                {
                    return;
                }

                toCell->setLocked(false);
                fromCell->setLocked(false);
                break;
            case 4: //failretrieve
                toCell = p->To < getUser()->BeltIdx ? BeltDialog->Grid[p->To] : InventoryDialog->Grid[p->To - getUser()->BeltIdx];
                fromCell = GuildDialog->StorageGrid[p->From];

                if (toCell == nullptr || fromCell == nullptr)
                {
                    return;
                }

                toCell->setLocked(false);
                fromCell->setLocked(false);
                break;
            case 5: //failmove
                fromCell = GuildDialog->StorageGrid[p->To];
                toCell = GuildDialog->StorageGrid[p->From];

                if (toCell == nullptr || fromCell == nullptr)
                {
                    return;
                }

                GuildDialog->StorageGrid[p->From]->setLocked(false);
                GuildDialog->StorageGrid[p->To]->setLocked(false);
                break;
        }
    }

    void GameScene::GuildStorageList(S::GuildStorageList *p)
    {
        for (int i = 0; i < p->Items.size(); i++)
        {
            if (i >= GuildDialog->StorageGrid.size())
            {
                break;
            }
            if (p->Items[i] == nullptr)
            {
                GuildDialog->StorageGrid[i]->setItem(nullptr);
                continue;
            }
            GuildDialog->StorageGrid[i]->setItem(p->Items[i]->Item);
            Bind(GuildDialog->StorageGrid[i]->getItem());
        }
    }

    void GameScene::MarriageRequest(S::MarriageRequest *p)
    {
        MirMessageBox *messageBox = new MirMessageBox(StringHelper::formatSimple("{0} has asked for your hand in marriage.", p->Name), MirMessageBoxButtons::YesNo);

        messageBox->YesButton->Click += [&] (o, e)
        {
            C::MarriageReply *tempVar = new C::MarriageReply();
            tempVar->AcceptInvite = true;
            Network::Enqueue(tempVar);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
        };
        messageBox->NoButton->Click += [&] (o, e)
        {
            C::MarriageReply *tempVar2 = new C::MarriageReply();
            tempVar2->AcceptInvite = false;
            Network::Enqueue(tempVar2);
            messageBox->Dispose();

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar2' statement was not added since tempVar2 was passed to a method or constructor. Handle memory management manually.
        };

        messageBox->Show();

        delete messageBox;
    }

    void GameScene::DivorceRequest(S::DivorceRequest *p)
    {
        MirMessageBox *messageBox = new MirMessageBox(StringHelper::formatSimple("{0} has requested a divorce", p->Name), MirMessageBoxButtons::YesNo);

        messageBox->YesButton->Click += [&] (o, e)
        {
            C::DivorceReply *tempVar = new C::DivorceReply();
            tempVar->AcceptInvite = true;
            Network::Enqueue(tempVar);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
        };
        messageBox->NoButton->Click += [&] (o, e)
        {
            C::DivorceReply *tempVar2 = new C::DivorceReply();
            tempVar2->AcceptInvite = false;
            Network::Enqueue(tempVar2);
            messageBox->Dispose();

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar2' statement was not added since tempVar2 was passed to a method or constructor. Handle memory management manually.
        };

        messageBox->Show();

        delete messageBox;
    }

    void GameScene::MentorRequest(S::MentorRequest *p)
    {
//C# TO C++ CONVERTER TODO TASK: There is no C++ equivalent to 'ToString':
        MirMessageBox *messageBox = new MirMessageBox(StringHelper::formatSimple("{0} (Level {1}) has requested you teach him the ways of the {2}.", p->Name, p->Level, GameScene::getUser()->Class.ToString()), MirMessageBoxButtons::YesNo);

        messageBox->YesButton->Click += [&] (o, e)
        {
            C::MentorReply *tempVar = new C::MentorReply();
            tempVar->AcceptInvite = true;
            Network::Enqueue(tempVar);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
        };
        messageBox->NoButton->Click += [&] (o, e)
        {
            C::MentorReply *tempVar2 = new C::MentorReply();
            tempVar2->AcceptInvite = false;
            Network::Enqueue(tempVar2);
            messageBox->Dispose();

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar2' statement was not added since tempVar2 was passed to a method or constructor. Handle memory management manually.
        };

        messageBox->Show();

        delete messageBox;
    }

    bool GameScene::UpdateGuildBuff(GuildBuff *buff, bool Remove)
    {
        for (int i = 0; i < GuildDialog->EnabledBuffs.size(); i++)
        {
            if (GuildDialog->EnabledBuffs[i]->Id == buff->Id)
            {
                if (Remove)
                {
                    GuildDialog->EnabledBuffs.erase(GuildDialog->EnabledBuffs.begin() + i);
                }
                else
                {
                    GuildDialog->EnabledBuffs[i] = buff;
                }
                return true;
            }
        }
        return false;
    }

    void GameScene::GuildBuffList(S::GuildBuffList *p)
    {
        //getting the list of all guildbuffs on server?
        if (p->GuildBuffs.size() > 0)
        {
            GuildDialog->GuildBuffInfos.clear();
        }
        for (int i = 0; i < p->GuildBuffs.size(); i++)
        {
            GuildDialog->GuildBuffInfos.push_back(p->GuildBuffs[i]);
        }
        //getting the list of all active/removedbuffs?
        for (int i = 0; i < p->ActiveBuffs.size(); i++)
        {
            //if (p.ActiveBuffs[i].ActiveTimeRemaining > 0)
            //    p.ActiveBuffs[i].ActiveTimeRemaining = Convert.ToInt32(CMain.Time / 1000) + (p.ActiveBuffs[i].ActiveTimeRemaining * 60);
            if (UpdateGuildBuff(p->ActiveBuffs[i], p->Remove == 1))
            {
                continue;
            }
            if (!(p->Remove == 1))
            {
                GuildDialog->EnabledBuffs.push_back(p->ActiveBuffs[i]);
                //CreateGuildBuff(p.ActiveBuffs[i]);
            }
        }

        for (int i = 0; i < GuildDialog->EnabledBuffs.size(); i++)
        {
            if (GuildDialog->EnabledBuffs[i]->Info == nullptr)
            {
                GuildDialog->EnabledBuffs[i]->Info = GuildDialog->FindGuildBuffInfo(GuildDialog->EnabledBuffs[i]->Id);
            }
        }

        ClientBuff *buff = Buffs.FirstOrDefault([&] (std::any e)
        {
            return e->Type == BuffType::Guild;
        });

        if (GuildDialog->EnabledBuffs.Any([&] (std::any e)
        {
            e::Active;
        }))
        {
            if (buff == nullptr)
            {
                buff = new ClientBuff();
                buff->Type = BuffType::Guild;
                buff->ObjectID = getUser()->ObjectID;
                buff->Caster = "Guild";
                buff->Infinite = true;
                buff->Values = std::vector<int>(0);

                Buffs.push_back(buff);
                BuffsDialog->CreateBuff(buff);
            }

            GuildDialog->UpdateActiveStats();
        }
        else
        {
            S::RemoveBuff *tempVar = new S::RemoveBuff();
            tempVar->ObjectID = getUser()->ObjectID;
            tempVar->Type = BuffType::Guild;
            RemoveBuff(tempVar);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
        }

        getUser()->RefreshStats();
    }

    void GameScene::TradeRequest(S::TradeRequest *p)
    {
        MirMessageBox *messageBox = new MirMessageBox(StringHelper::formatSimple("Player {0} has requested to trade with you.", p->Name), MirMessageBoxButtons::YesNo);

        messageBox->YesButton->Click += [&] (o, e)
        {
            C::TradeReply *tempVar = new C::TradeReply();
            tempVar->AcceptInvite = true;
            Network::Enqueue(tempVar);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
        };
        messageBox->NoButton->Click += [&] (o, e)
        {
            C::TradeReply *tempVar2 = new C::TradeReply();
            tempVar2->AcceptInvite = false;
            Network::Enqueue(tempVar2);
            messageBox->Dispose();

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar2' statement was not added since tempVar2 was passed to a method or constructor. Handle memory management manually.
        };

        messageBox->Show();

        delete messageBox;
    }

    void GameScene::TradeAccept(S::TradeAccept *p)
    {
        GuestTradeDialog->GuestName = p->Name;
        TradeDialog->TradeAccept();
    }

    void GameScene::TradeGold(S::TradeGold *p)
    {
        GuestTradeDialog->GuestGold = p->Amount;
        TradeDialog->ChangeLockState(false);
        TradeDialog->RefreshInterface();
    }

    void GameScene::TradeItem(S::TradeItem *p)
    {
        GuestTradeDialog::GuestItems = p->TradeItems;
        TradeDialog->ChangeLockState(false);
        TradeDialog->RefreshInterface();
    }

    void GameScene::TradeConfirm()
    {
        TradeDialog->TradeReset();
    }

    void GameScene::TradeCancel(S::TradeCancel *p)
    {
        if (p->Unlock)
        {
            TradeDialog->ChangeLockState(false);
        }
        else
        {
            TradeDialog->TradeReset();

            MirMessageBox *messageBox = new MirMessageBox("Deal cancelled.\r\nTo deal correctly you must face the other party.", MirMessageBoxButtons::OK);
            messageBox->Show();

            delete messageBox;
        }
    }

    void GameScene::NPCAwakening()
    {
        if (NPCAwakeDialog->getVisible() != true)
        {
            NPCAwakeDialog->Show();
        }
    }

    void GameScene::NPCDisassemble()
    {
        if (!NPCDialog->getVisible())
        {
            return;
        }
        NPCDropDialog->PType = PanelType::Disassemble;
        NPCDropDialog->Show();
    }

    void GameScene::NPCDowngrade()
    {
        if (!NPCDialog->getVisible())
        {
            return;
        }
        NPCDropDialog->PType = PanelType::Downgrade;
        NPCDropDialog->Show();
    }

    void GameScene::NPCReset()
    {
        if (!NPCDialog->getVisible())
        {
            return;
        }
        NPCDropDialog->PType = PanelType::Reset;
        NPCDropDialog->Show();
    }

    void GameScene::AwakeningNeedMaterials(S::AwakeningNeedMaterials *p)
    {
        NPCAwakeDialog->setNeedItems(p->Materials, p->MaterialsCount);
    }

    void GameScene::AwakeningLockedItem(S::AwakeningLockedItem *p)
    {
        MirItemCell *cell = InventoryDialog->GetCell(p->UniqueID);
        if (cell != nullptr)
        {
            cell->setLocked(p->Locked);
        }
    }

    void GameScene::Awakening(S::Awakening *p)
    {
        if (NPCAwakeDialog->getVisible())
        {
            NPCAwakeDialog->Hide();
        }
        if (InventoryDialog->getVisible())
        {
            InventoryDialog->Hide();
        }

        MirItemCell *cell = InventoryDialog->GetCell(static_cast<unsigned long long>(p->removeID));
        if (cell != nullptr)
        {
            cell->setLocked(false);
            cell->setItem(nullptr);
        }

        for (int i = 0; i < InventoryDialog->Grid.size(); i++)
        {
            if (InventoryDialog->Grid[i]->getLocked() == true)
            {
                InventoryDialog->Grid[i]->setLocked(false);

                //if (InventoryDialog.Grid[i].Item.UniqueID == (ulong)p.removeID)
                //{
                //    InventoryDialog.Grid[i].Item = null;
                //}
            }
        }

        for (int i = 0; i < NPCAwakeDialog::ItemsIdx.size(); i++)
        {
            NPCAwakeDialog::ItemsIdx[i] = 0;
        }

        MirMessageBox *messageBox = nullptr;

        switch (p->result)
        {
            case -4:
                messageBox = new MirMessageBox("You have not supplied enough materials.", MirMessageBoxButtons::OK);
                MapControl->setAwakeningAction(false);
                break;
            case -3:
                messageBox = new MirMessageBox(GameLanguage::LowGold, MirMessageBoxButtons::OK);
                MapControl->setAwakeningAction(false);
                break;
            case -2:
                messageBox = new MirMessageBox("Awakening already at maximum level.", MirMessageBoxButtons::OK);
                MapControl->setAwakeningAction(false);
                break;
            case -1:
                messageBox = new MirMessageBox("Cannot awaken this item.", MirMessageBoxButtons::OK);
                MapControl->setAwakeningAction(false);
                break;
            case 0:
                //messageBox = new MirMessageBox("Upgrade Failed.", MirMessageBoxButtons.OK);
                break;
            case 1:
                //messageBox = new MirMessageBox("Upgrade Success.", MirMessageBoxButtons.OK);
                break;

        }

        if (messageBox != nullptr)
        {
            messageBox->Show();
        }

//C# TO C++ CONVERTER TODO TASK: A 'delete messageBox' statement was not added since messageBox was passed to a method or constructor. Handle memory management manually.
    }

    void GameScene::ReceiveMail(S::ReceiveMail *p)
    {
        NewMail = false;
        NewMailCounter = 0;
        getUser()->Mail.clear();

        getUser()->Mail = p->Mail.OrderByDescending([&] (std::any e)
        {
            return !e::Locked;
        }).ThenByDescending([&] (std::any e)
        {
            e::DateSent;
        }).ToList();

        for (auto mail : getUser()->Mail)
        {
            for (auto itm : *mail->Items)
            {
                Bind(itm);
            }
        }

        //display new mail received
        if (getUser()->Mail.Any([&] (std::any e)
        {
            return e->Opened == false;
        }))
        {
            NewMail = true;
        }

        GameScene::Scene->MailListDialog->UpdateInterface();
    }

    void GameScene::MailLockedItem(S::MailLockedItem *p)
    {
        MirItemCell *cell = InventoryDialog->GetCell(p->UniqueID);
        if (cell != nullptr)
        {
            cell->setLocked(p->Locked);
        }
    }

    void GameScene::MailSendRequest(S::MailSendRequest *p)
    {
        MirInputBox *inputBox = new MirInputBox("Please enter the name of the person you would like to mail.");

        inputBox->OKButton->Click += [&] (o1, e1)
        {
            GameScene::Scene->MailComposeParcelDialog->ComposeMail(inputBox->InputTextBox->getText());
            GameScene::Scene->InventoryDialog->Show();
    
            //open letter dialog, pass in name
            inputBox->Dispose();
        };

        inputBox->Show();

        delete inputBox;
    }

    void GameScene::MailSent(S::MailSent *p)
    {
        for (int i = 0; i < InventoryDialog->Grid.size(); i++)
        {
            if (InventoryDialog->Grid[i]->getLocked() == true)
            {
                InventoryDialog->Grid[i]->setLocked(false);
            }
        }

        for (int i = 0; i < BeltDialog->Grid.size(); i++)
        {
            if (BeltDialog->Grid[i]->getLocked() == true)
            {
                BeltDialog->Grid[i]->setLocked(false);
            }
        }

        GameScene::Scene->MailComposeParcelDialog->Hide();
    }

    void GameScene::ParcelCollected(S::ParcelCollected *p)
    {
        switch (p->Result)
        {
            case -1:
            {
                MirMessageBox *messageBox = new MirMessageBox(std::string::Format("No parcels to collect."), MirMessageBoxButtons::OK);
                messageBox->Show();
                break;

            delete messageBox;
            }
            case 0:
                messageBox = new MirMessageBox(std::string::Format("All parcels have been collected."), MirMessageBoxButtons::OK);
                messageBox::Show();
                break;
            case 1:
                GameScene::Scene->MailReadParcelDialog->Hide();
                break;
        }
    }

    void GameScene::ResizeInventory(S::ResizeInventory *p)
    {
        Array::Resize(getUser()->Inventory, p->Size);
        InventoryDialog->RefreshInventory2();
    }

    void GameScene::ResizeStorage(S::ResizeStorage *p)
    {
        Array::Resize(Storage, p->Size);
        getUser()->HasExpandedStorage = p->HasExpandedStorage;
        getUser()->ExpandedStorageExpiryTime = p->ExpiryTime;

        StorageDialog->RefreshStorage2();
    }

    void GameScene::MailCost(S::MailCost *p)
    {
        if (GameScene::Scene->MailComposeParcelDialog->getVisible())
        {
            if (p->Cost > 0)
            {
                SoundManager::PlaySound(SoundList::Gold);
            }

            GameScene::Scene->MailComposeParcelDialog->ParcelCostLabel->setText(std::to_string(p->Cost));
        }
    }

    void GameScene::AddQuestItem(UserItem *item)
    {
        Redraw();

        if (item->Info->StackSize > 1) //Stackable
        {
            for (int i = 0; i < getUser()->QuestInventory.size(); i++)
            {
                UserItem *temp = getUser()->QuestInventory[i];
                if (temp == nullptr || item->Info != temp->Info || temp->Count >= temp->Info->StackSize)
                {
                    continue;
                }

                if (item->Count + temp->Count <= temp->Info->StackSize)
                {
                    temp->Count += item->Count;
                    return;
                }
                item->Count -= static_cast<unsigned short>(temp->Info->StackSize - temp->Count);
                temp->Count = temp->Info->StackSize;
            }
        }

        for (int i = 0; i < getUser()->QuestInventory.size(); i++)
        {
            if (getUser()->QuestInventory[i] != nullptr)
            {
                continue;
            }
            getUser()->QuestInventory[i] = item;
            return;
        }
    }

    void GameScene::RequestReincarnation()
    {
        if (CMain::Time > getUser()->DeadTime && getUser()->CurrentAction == MirAction::Dead)
        {
            MirMessageBox *messageBox = new MirMessageBox("Would you like to be revived?", MirMessageBoxButtons::YesNo);

            messageBox->YesButton->Click += [&] (o, e)
            {
                C::AcceptReincarnation tempVar();
                Network::Enqueue(&tempVar);
            };

            messageBox->Show();

            delete messageBox;
        }
    }

    void GameScene::NewIntelligentCreature(S::NewIntelligentCreature *p)
    {
        getUser()->IntelligentCreatures.push_back(p->Creature);

        MirInputBox *inputBox = new MirInputBox("Please give your creature a name.");
        inputBox->InputTextBox->setText(GameScene::getUser()->IntelligentCreatures[getUser()->IntelligentCreatures.size() - 1]->CustomName);
        inputBox->OKButton->Click += [&] (o1, e1)
        {
            if (IntelligentCreatureDialog->getVisible())
            {
                IntelligentCreatureDialog->Update(); //refresh changes
            }
            GameScene::getUser()->IntelligentCreatures[getUser()->IntelligentCreatures.size() - 1]->CustomName = inputBox->InputTextBox->getText();
            C::UpdateIntelligentCreature *tempVar = new C::UpdateIntelligentCreature();
            tempVar->Creature = GameScene::getUser()->IntelligentCreatures[getUser()->IntelligentCreatures.size() - 1];
            Network::Enqueue(tempVar);
            inputBox->Dispose();

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
        };
        inputBox->Show();

        delete inputBox;
    }

    void GameScene::UpdateIntelligentCreatureList(S::UpdateIntelligentCreatureList *p)
    {
        getUser()->CreatureSummoned = p->CreatureSummoned;
        getUser()->SummonedCreatureType = p->SummonedCreatureType;
        getUser()->PearlCount = p->PearlCount;
        if (p->CreatureList.size() != getUser()->IntelligentCreatures.size())
        {
            getUser()->IntelligentCreatures.clear();
            for (int i = 0; i < p->CreatureList.size(); i++)
            {
                getUser()->IntelligentCreatures.push_back(p->CreatureList[i]);
            }

            for (int i = 0; i < IntelligentCreatureDialog->CreatureButtons.size(); i++)
            {
                IntelligentCreatureDialog->CreatureButtons[i]->Clear();
            }

            IntelligentCreatureDialog->Hide();
        }
        else
        {
            for (int i = 0; i < p->CreatureList.size(); i++)
            {
                getUser()->IntelligentCreatures[i] = p->CreatureList[i];
            }
            if (IntelligentCreatureDialog->getVisible())
            {
                IntelligentCreatureDialog->Update();
            }
        }
    }

    void GameScene::IntelligentCreatureEnableRename(S::IntelligentCreatureEnableRename *p)
    {
        IntelligentCreatureDialog->CreatureRenameButton->setVisible(true);
        if (IntelligentCreatureDialog->getVisible())
        {
            IntelligentCreatureDialog->Update();
        }
    }

    void GameScene::IntelligentCreaturePickup(S::IntelligentCreaturePickup *p)
    {
        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];
            if (ob->ObjectID != p->ObjectID)
            {
                continue;
            }

            MonsterObject *monOb = static_cast<MonsterObject*>(ob);

            if (monOb != nullptr)
            {
                monOb->PlayPickupSound();
            }
        }
    }

    void GameScene::FriendUpdate(S::FriendUpdate *p)
    {
        GameScene::Scene->FriendDialog->Friends = p->Friends;

        if (GameScene::Scene->FriendDialog->getVisible())
        {
            GameScene::Scene->FriendDialog->Update(false);
        }
    }

    void GameScene::LoverUpdate(S::LoverUpdate *p)
    {
        GameScene::Scene->RelationshipDialog->LoverName = p->Name;
        GameScene::Scene->RelationshipDialog->Date = p->Date;
        GameScene::Scene->RelationshipDialog->MapName = p->MapName;
        GameScene::Scene->RelationshipDialog->MarriedDays = p->MarriedDays;
        GameScene::Scene->RelationshipDialog->UpdateInterface();
    }

    void GameScene::MentorUpdate(S::MentorUpdate *p)
    {
        GameScene::Scene->MentorDialog->MentorName = p->Name;
        GameScene::Scene->MentorDialog->MentorLevel = p->Level;
        GameScene::Scene->MentorDialog->MentorOnline = p->Online;
        GameScene::Scene->MentorDialog->MenteeEXP = p->MenteeEXP;

        GameScene::Scene->MentorDialog->UpdateInterface();
    }

    void GameScene::GameShopUpdate(S::GameShopInfo *p)
    {
        p->Item->Stock = p->StockLevel;
        GameShopInfoList.push_back(p->Item);
        if (p->Item->Date > DateTime::Now.AddDays(-7))
        {
            GameShopDialog->New->setVisible(true);
        }
    }

    void GameScene::GameShopStock(S::GameShopStock *p)
    {
        for (int i = 0; i < GameShopInfoList.size(); i++)
        {
            if (GameShopInfoList[i]->GIndex == p->GIndex)
            {
                if (p->StockLevel == 0)
                {
                    GameShopInfoList.Remove(GameShopInfoList[i]);
                }
                else
                {
                    GameShopInfoList[i]->Stock = p->StockLevel;
                }

                if (GameShopDialog->getVisible())
                {
                    GameShopDialog->UpdateShop();
                }
            }
        }
    }

    void GameScene::AddItem(UserItem *item)
    {
        Redraw();

        if (item->Info->StackSize > 1) //Stackable
        {
            for (int i = 0; i < getUser()->Inventory.size(); i++)
            {
                UserItem *temp = getUser()->Inventory[i];
                if (temp == nullptr || item->Info != temp->Info || temp->Count >= temp->Info->StackSize)
                {
                    continue;
                }

                if (item->Count + temp->Count <= temp->Info->StackSize)
                {
                    temp->Count += item->Count;
                    return;
                }
                item->Count -= static_cast<unsigned short>(temp->Info->StackSize - temp->Count);
                temp->Count = temp->Info->StackSize;
            }
        }

        if (item->Info->Type == ItemType::Potion || item->Info->Type == ItemType::Scroll || (item->Info->Type == ItemType::Script && item->Info->Effect == 1))
        {
            for (int i = 0; i < getUser()->BeltIdx - 2; i++)
            {
                if (getUser()->Inventory[i] != nullptr)
                {
                    continue;
                }
                getUser()->Inventory[i] = item;
                return;
            }
        }
        else if (item->Info->Type == ItemType::Amulet)
        {
            for (int i = 4; i < getUser()->BeltIdx; i++)
            {
                if (getUser()->Inventory[i] != nullptr)
                {
                    continue;
                }
                getUser()->Inventory[i] = item;
                return;
            }
        }
        else
        {
            for (int i = getUser()->BeltIdx; i < getUser()->Inventory.size(); i++)
            {
                if (getUser()->Inventory[i] != nullptr)
                {
                    continue;
                }
                getUser()->Inventory[i] = item;
                return;
            }
        }

        for (int i = 0; i < getUser()->Inventory.size(); i++)
        {
            if (getUser()->Inventory[i] != nullptr)
            {
                continue;
            }
            getUser()->Inventory[i] = item;
            return;
        }
    }

    void GameScene::Bind(UserItem *item)
    {
        for (int i = 0; i < ItemInfoList.size(); i++)
        {
            if (ItemInfoList[i]->Index != item->ItemIndex)
            {
                continue;
            }

            item->Info = ItemInfoList[i];

            for (int s = 0; s < item->Slots.size(); s++)
            {
                if (item->Slots[s] == nullptr)
                {
                    continue;
                }

                Bind(item->Slots[s]);
            }

            return;
        }
    }

    void GameScene::BindQuest(ClientQuestProgress *quest)
    {
        for (int i = 0; i < QuestInfoList.size(); i++)
        {
            if (QuestInfoList[i]->Index != quest->Id)
            {
                continue;
            }

            quest->QuestInfo = QuestInfoList[i];

            return;
        }
    }

    Color *GameScene::GradeNameColor(ItemGrade grade)
    {
        switch (grade)
        {
            case ItemGrade::Common:
                return Color::Yellow;
            case ItemGrade::Rare:
                return Color::DeepSkyBlue;
            case ItemGrade::Legendary:
                return Color::DarkOrange;
            case ItemGrade::Mythical:
                return Color::Plum;
            default:
                return Color::Yellow;
        }
    }

    void GameScene::DisposeItemLabel()
    {
        if (ItemLabel != nullptr && !ItemLabel->isDisposed())
        {
            ItemLabel->Dispose();
        }
        ItemLabel = nullptr;
    }

    void GameScene::DisposeMailLabel()
    {
        if (MailLabel != nullptr && !MailLabel->isDisposed())
        {
            MailLabel->Dispose();
        }
        MailLabel = nullptr;
    }

    void GameScene::DisposeMemoLabel()
    {
        if (MemoLabel != nullptr && !MemoLabel->isDisposed())
        {
            MemoLabel->Dispose();
        }
        MemoLabel = nullptr;
    }

    void GameScene::DisposeGuildBuffLabel()
    {
        if (GuildBuffLabel != nullptr && !GuildBuffLabel->isDisposed())
        {
            GuildBuffLabel->Dispose();
        }
        GuildBuffLabel = nullptr;
    }

    MirControl *GameScene::NameInfoLabel(UserItem *item, bool inspect, bool hideDura)
    {
        unsigned short level = inspect ? InspectDialog->Level : MapObject::User->Level;
        MirClass job = inspect ? InspectDialog->Class : MapObject::User->Class;
        HoverItem = item;
        ItemInfo *realItem = Functions::GetRealItem(item->Info, level, job, ItemInfoList);

        std::string GradeString = "";
        switch (HoverItem->Info->Grade)
        {
            case ItemGrade::None:
                break;
            case ItemGrade::Common:
                GradeString = GameLanguage::ItemGradeCommon;
                break;
            case ItemGrade::Rare:
                GradeString = GameLanguage::ItemGradeRare;
                break;
            case ItemGrade::Legendary:
                GradeString = GameLanguage::ItemGradeLegendary;
                break;
            case ItemGrade::Mythical:
                GradeString = GameLanguage::ItemGradeMythical;
                break;
        }
        MirLabel *nameLabel = new MirLabel();
        nameLabel->setAutoSize(true);
        nameLabel->setForeColour(GradeNameColor(HoverItem->Info->Grade));
        Point tempVar(4, 4);
        nameLabel->setLocation(&tempVar);
        nameLabel->setOutLine(true);
        nameLabel->setParent(ItemLabel);
        nameLabel->setText(HoverItem->Info->Grade != ItemGrade::None ? StringHelper::formatSimple("{0}{1}{2}", HoverItem->Info->getFriendlyName(), "\n", GradeString) : HoverItem->Info->getFriendlyName());

        if (HoverItem->RefineAdded > 0)
        {
            nameLabel->setText("(*)" + nameLabel->getText());
        }

        Size tempVar2(std::max(ItemLabel->getSize()->Width, nameLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, nameLabel->getDisplayRectangle()->Bottom));
        ItemLabel->setSize(&tempVar2);

        std::string text = "";

        if (HoverItem->Info->Durability > 0 && !hideDura)
        {
            switch (HoverItem->Info->Type)
            {
                case ItemType::Amulet:
                    text += StringHelper::formatSimple(" Usage {0}/{1}", HoverItem->CurrentDura, HoverItem->MaxDura);
                    break;
                case ItemType::Ore:
                    text += StringHelper::formatSimple(" Purity {0}", std::floor(HoverItem->CurrentDura / 1000));
                    break;
                case ItemType::Meat:
                    text += StringHelper::formatSimple(" Quality {0}", std::floor(HoverItem->CurrentDura / 1000));
                    break;
                case ItemType::Mount:
                    text += StringHelper::formatSimple(" Loyalty {0} / {1}", HoverItem->CurrentDura, HoverItem->MaxDura);
                    break;
                case ItemType::Food:
                    text += StringHelper::formatSimple(" Nutrition {0}", HoverItem->CurrentDura);
                    break;
                case ItemType::Gem:
                    break;
                case ItemType::Potion:
                    break;
                case ItemType::Transform:
                    break;
                case ItemType::Pets:
                    if (HoverItem->Info->Shape == 26 || HoverItem->Info->Shape == 28) //WonderDrug, Knapsack
                    {
                        std::string strTime = Functions::PrintTimeSpanFromSeconds((HoverItem->CurrentDura * 3600), false);
                        text += StringHelper::formatSimple(" Duration {0}", strTime);
                    }
                    break;
                default:
                    text += StringHelper::formatSimple(" {0} {1}/{2}", GameLanguage::Durability, std::floor(HoverItem->CurrentDura / 1000), std::floor(HoverItem->MaxDura / 1000));
                    break;
            }
        }

        std::string baseText = "";
        switch (HoverItem->Info->Type)
        {
            case ItemType::Nothing:
                break;
            case ItemType::Weapon:
                baseText = GameLanguage::ItemTypeWeapon;
                break;
            case ItemType::Armour:
                baseText = GameLanguage::ItemTypeArmour;
                break;
            case ItemType::Helmet:
                baseText = GameLanguage::ItemTypeHelmet;
                break;
            case ItemType::Necklace:
                baseText = GameLanguage::ItemTypeNecklace;
                break;
            case ItemType::Bracelet:
                baseText = GameLanguage::ItemTypeBracelet;
                break;
            case ItemType::Ring:
                baseText = GameLanguage::ItemTypeRing;
                break;
            case ItemType::Amulet:
                baseText = GameLanguage::ItemTypeAmulet;
                break;
            case ItemType::Belt:
                baseText = GameLanguage::ItemTypeBelt;
                break;
            case ItemType::Boots:
                baseText = GameLanguage::ItemTypeBoots;
                break;
            case ItemType::Stone:
                baseText = GameLanguage::ItemTypeStone;
                break;
            case ItemType::Torch:
                baseText = GameLanguage::ItemTypeTorch;
                break;
            case ItemType::Potion:
                baseText = GameLanguage::ItemTypePotion;
                break;
            case ItemType::Ore:
                baseText = GameLanguage::ItemTypeOre;
                break;
            case ItemType::Meat:
                baseText = GameLanguage::ItemTypeMeat;
                break;
            case ItemType::CraftingMaterial:
                baseText = GameLanguage::ItemTypeCraftingMaterial;
                break;
            case ItemType::Scroll:
                baseText = GameLanguage::ItemTypeScroll;
                break;
            case ItemType::Gem:
                baseText = GameLanguage::ItemTypeGem;
                break;
            case ItemType::Mount:
                baseText = GameLanguage::ItemTypeMount;
                break;
            case ItemType::Book:
                baseText = GameLanguage::ItemTypeBook;
                break;
            case ItemType::Script:
                baseText = GameLanguage::ItemTypeScript;
                break;
            case ItemType::Reins:
                baseText = GameLanguage::ItemTypeReins;
                break;
            case ItemType::Bells:
                baseText = GameLanguage::ItemTypeBells;
                break;
            case ItemType::Saddle:
                baseText = GameLanguage::ItemTypeSaddle;
                break;
            case ItemType::Ribbon:
                baseText = GameLanguage::ItemTypeRibbon;
                break;
            case ItemType::Mask:
                baseText = GameLanguage::ItemTypeMask;
                break;
            case ItemType::Food:
                baseText = GameLanguage::ItemTypeFood;
                break;
            case ItemType::Hook:
                baseText = GameLanguage::ItemTypeHook;
                break;
            case ItemType::Float:
                baseText = GameLanguage::ItemTypeFloat;
                break;
            case ItemType::Bait:
                baseText = GameLanguage::ItemTypeBait;
                break;
            case ItemType::Finder:
                baseText = GameLanguage::ItemTypeFinder;
                break;
            case ItemType::Reel:
                baseText = GameLanguage::ItemTypeReel;
                break;
            case ItemType::Fish:
                baseText = GameLanguage::ItemTypeFish;
                break;
            case ItemType::Quest:
                baseText = GameLanguage::ItemTypeQuest;
                break;
            case ItemType::Awakening:
                baseText = GameLanguage::ItemTypeAwakening;
                break;
            case ItemType::Pets:
                baseText = GameLanguage::ItemTypePets;
                break;
            case ItemType::Transform:
                baseText = GameLanguage::ItemTypeTransform;
                break;
            case ItemType::Deco:
                baseText = GameLanguage::ItemTypeDeco;
                break;
        }

        if (HoverItem->WeddingRing != -1)
        {
            baseText = GameLanguage::WeddingRing;
        }

        baseText = std::string::Format(GameLanguage::ItemTextFormat, baseText, baseText.empty() ? "" : "\n", GameLanguage::Weight, std::to_string(HoverItem->getWeight()) + text);

        MirLabel *etcLabel = new MirLabel();
        etcLabel->setAutoSize(true);
        etcLabel->setForeColour(Color::White);
        Point tempVar3(4, nameLabel->getDisplayRectangle()->Bottom);
        etcLabel->setLocation(&tempVar3);
        etcLabel->setOutLine(true);
        etcLabel->setParent(ItemLabel);
        etcLabel->setText(baseText);

        Size tempVar4(std::max(ItemLabel->getSize()->Width, etcLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, etcLabel->getDisplayRectangle()->Bottom + 4));
        ItemLabel->setSize(&tempVar4);

        #pragma region OUTLINE
        MirControl *outLine = new MirControl();
        outLine->setBackColour(Color::FromArgb(255, 50, 50, 50));
        outLine->setBorder(true);
        outLine->setBorderColour(Color::Gray);
        outLine->setNotControl(true);
        outLine->setParent(ItemLabel);
        outLine->setOpacity(0.4F);
        Point tempVar5(0, 0);
        outLine->setLocation(&tempVar5);
        outLine->setSize(ItemLabel->getSize());
        #pragma endregion

//C# TO C++ CONVERTER TODO TASK: A 'delete outLine' statement was not added since outLine was used in a 'return' or 'throw' statement.
        delete etcLabel;
        delete nameLabel;
        return outLine;
    }

    MirControl *GameScene::AttackInfoLabel(UserItem *item, bool Inspect, bool hideAdded)
    {
        unsigned short level = Inspect ? InspectDialog->Level : MapObject::User->Level;
        MirClass job = Inspect ? InspectDialog->Class : MapObject::User->Class;
        HoverItem = item;
        ItemInfo *realItem = Functions::GetRealItem(item->Info, level, job, ItemInfoList);

        Size tempVar(ItemLabel->getSize()->Width, ItemLabel->getSize()->Height + 4);
        ItemLabel->setSize(&tempVar);

        bool fishingItem = false;

        switch (HoverItem->Info->Type)
        {
            case ItemType::Hook:
            case ItemType::Float:
            case ItemType::Bait:
            case ItemType::Finder:
            case ItemType::Reel:
                fishingItem = true;
                break;
            case ItemType::Weapon:
                if (Globals::FishingRodShapes.Contains(HoverItem->Info->Shape))
                {
                    fishingItem = true;
                }
                break;
            default:
                fishingItem = false;
                break;
        }

        int count = 0;
        int minValue = 0;
        int maxValue = 0;
        int addValue = 0;
        std::string text = "";

        #pragma region Dura gem
        minValue = realItem->Durability;

        if (minValue > 0 && realItem->Type == ItemType::Gem)
        {
            count++;
            text = StringHelper::formatSimple("Adds +{0} Durability", minValue / 1000);
            MirLabel *DuraLabel = new MirLabel();
            DuraLabel->setAutoSize(true);
            DuraLabel->setForeColour(Color::White);
            Point tempVar2(4, ItemLabel->getDisplayRectangle()->Bottom);
            DuraLabel->setLocation(&tempVar2);
            DuraLabel->setOutLine(true);
            DuraLabel->setParent(ItemLabel);
            DuraLabel->setText(text);

            Size tempVar3(std::max(ItemLabel->getSize()->Width, DuraLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, DuraLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar3);

            delete DuraLabel;
        }

        #pragma endregion

        #pragma region DC
        minValue = realItem->Stats[Stat::MinDC];
        maxValue = realItem->Stats[Stat::MaxDC];
        addValue = (!hideAdded && (!HoverItem->Info->NeedIdentify || HoverItem->Identified)) ? HoverItem->AddedStats[Stat::MaxDC] : 0;

        if (minValue > 0 || maxValue > 0 || addValue > 0)
        {
            count++;
            if (HoverItem->Info->Type != ItemType::Gem)
            {
                text = std::string::Format(addValue > 0 ? GameLanguage::DC : GameLanguage::DC2, minValue, maxValue + addValue, addValue);
            }
            else
            {
                text = StringHelper::formatSimple("Adds +{0} DC", minValue + maxValue + addValue);
            }
            MirLabel *DCLabel = new MirLabel();
            DCLabel->setAutoSize(true);
            DCLabel->setForeColour(addValue > 0 ? Color::Cyan : Color::White);
            Point tempVar4(4, ItemLabel->getDisplayRectangle()->Bottom);
            DCLabel->setLocation(&tempVar4);
            DCLabel->setOutLine(true);
            DCLabel->setParent(ItemLabel);
            DCLabel->setText(text);

            Size tempVar5(std::max(ItemLabel->getSize()->Width, DCLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, DCLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar5);

            delete DCLabel;
        }

        #pragma endregion

        #pragma region MC

        minValue = realItem->Stats[Stat::MinMC];
        maxValue = realItem->Stats[Stat::MaxMC];
        addValue = (!hideAdded && (!HoverItem->Info->NeedIdentify || HoverItem->Identified)) ? HoverItem->AddedStats[Stat::MaxMC] : 0;

        if (minValue > 0 || maxValue > 0 || addValue > 0)
        {
            count++;
            if (HoverItem->Info->Type != ItemType::Gem)
            {
                text = std::string::Format(addValue > 0 ? GameLanguage::MC : GameLanguage::MC2, minValue, maxValue + addValue, addValue);
            }
            else
            {
                text = StringHelper::formatSimple("Adds +{0} MC", minValue + maxValue + addValue);
            }
            MirLabel *MCLabel = new MirLabel();
            MCLabel->setAutoSize(true);
            MCLabel->setForeColour(addValue > 0 ? Color::Cyan : Color::White);
            Point tempVar6(4, ItemLabel->getDisplayRectangle()->Bottom);
            MCLabel->setLocation(&tempVar6);
            MCLabel->setOutLine(true);
            MCLabel->setParent(ItemLabel);
            MCLabel->setText(text);

            Size tempVar7(std::max(ItemLabel->getSize()->Width, MCLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, MCLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar7);

            delete MCLabel;
        }

        #pragma endregion

        #pragma region SC

        minValue = realItem->Stats[Stat::MinSC];
        maxValue = realItem->Stats[Stat::MaxSC];
        addValue = (!hideAdded && (!HoverItem->Info->NeedIdentify || HoverItem->Identified)) ? HoverItem->AddedStats[Stat::MaxSC] : 0;

        if (minValue > 0 || maxValue > 0 || addValue > 0)
        {
            count++;
            if (HoverItem->Info->Type != ItemType::Gem)
            {
                text = std::string::Format(addValue > 0 ? GameLanguage::SC : GameLanguage::SC2, minValue, maxValue + addValue, addValue);
            }
            else
            {
                text = StringHelper::formatSimple("Adds +{0} SC", minValue + maxValue + addValue);
            }
            MirLabel *SCLabel = new MirLabel();
            SCLabel->setAutoSize(true);
            SCLabel->setForeColour(addValue > 0 ? Color::Cyan : Color::White);
            Point tempVar8(4, ItemLabel->getDisplayRectangle()->Bottom);
            SCLabel->setLocation(&tempVar8);
            SCLabel->setOutLine(true);
            SCLabel->setParent(ItemLabel);
            SCLabel->setText(text);

            Size tempVar9(std::max(ItemLabel->getSize()->Width, SCLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, SCLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar9);

            delete SCLabel;
        }

        #pragma endregion

        #pragma region LUCK / SUCCESS

        minValue = realItem->Stats[Stat::Luck];
        maxValue = 0;
        addValue = (!hideAdded && (!HoverItem->Info->NeedIdentify || HoverItem->Identified)) ? HoverItem->AddedStats[Stat::Luck] : 0;

        if (minValue != 0 || addValue != 0)
        {
            count++;

            if (realItem->Type == ItemType::Pets && realItem->Shape == 28)
            {
                text = StringHelper::formatSimple("BagWeight + {0}% ", minValue + addValue);
            }
            else if (realItem->Type == ItemType::Potion && realItem->Shape == 4)
            {
                text = StringHelper::formatSimple("Exp + {0}% ", minValue + addValue);
            }
            else
            {
                text = StringHelper::formatSimple(minValue + addValue > 0 ? GameLanguage::Luck: "Curse + {0}", std::abs(minValue + addValue));
            }

            MirLabel *LUCKLabel = new MirLabel();
            LUCKLabel->setAutoSize(true);
            LUCKLabel->setForeColour(addValue > 0 ? Color::Cyan : Color::White);
            Point tempVar10(4, ItemLabel->getDisplayRectangle()->Bottom);
            LUCKLabel->setLocation(&tempVar10);
            LUCKLabel->setOutLine(true);
            LUCKLabel->setParent(ItemLabel);
            LUCKLabel->setText(text);

            Size tempVar11(std::max(ItemLabel->getSize()->Width, LUCKLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, LUCKLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar11);

            delete LUCKLabel;
        }

        #pragma endregion



        #pragma region ACC

        minValue = realItem->Stats[Stat::Accuracy];
        maxValue = 0;
        addValue = (!hideAdded && (!HoverItem->Info->NeedIdentify || HoverItem->Identified)) ? HoverItem->AddedStats[Stat::Accuracy] : 0;

        if (minValue > 0 || maxValue > 0 || addValue > 0)
        {
            count++;
            if (HoverItem->Info->Type != ItemType::Gem)
            {
                text = std::string::Format(addValue > 0 ? GameLanguage::Accuracy : GameLanguage::Accuracy2, minValue + addValue, addValue);
            }
            else
            {
                text = StringHelper::formatSimple("Adds +{0} Accuracy", minValue + maxValue + addValue);
            }
            MirLabel *ACCLabel = new MirLabel();
            ACCLabel->setAutoSize(true);
            ACCLabel->setForeColour(addValue > 0 ? Color::Cyan : Color::White);
            Point tempVar12(4, ItemLabel->getDisplayRectangle()->Bottom);
            ACCLabel->setLocation(&tempVar12);
            ACCLabel->setOutLine(true);
            ACCLabel->setParent(ItemLabel);
            ACCLabel->setText(text);

            Size tempVar13(std::max(ItemLabel->getSize()->Width, ACCLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, ACCLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar13);

            delete ACCLabel;
        }

        #pragma endregion

        #pragma region HOLY

        minValue = realItem->Stats[Stat::Holy];
        maxValue = 0;
        addValue = 0;

        if (minValue > 0 || maxValue > 0 || addValue > 0)
        {
            count++;
            MirLabel *HOLYLabel = new MirLabel();
            HOLYLabel->setAutoSize(true);
            HOLYLabel->setForeColour(addValue > 0 ? Color::Cyan : Color::White);
            Point tempVar14(4, ItemLabel->getDisplayRectangle()->Bottom);
            HOLYLabel->setLocation(&tempVar14);
            HOLYLabel->setOutLine(true);
            HOLYLabel->setParent(ItemLabel);
            HOLYLabel->setText(std::string::Format(addValue > 0 ? GameLanguage::Holy : GameLanguage::Holy2, minValue + addValue, addValue));

            Size tempVar15(std::max(ItemLabel->getSize()->Width, HOLYLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, HOLYLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar15);

            delete HOLYLabel;
        }

        #pragma endregion

        #pragma region ASPEED

        minValue = realItem->Stats[Stat::AttackSpeed];
        maxValue = 0;
        addValue = (!hideAdded && (!HoverItem->Info->NeedIdentify || HoverItem->Identified)) ? HoverItem->AddedStats[Stat::AttackSpeed] : 0;

        if (minValue != 0 || maxValue != 0 || addValue != 0)
        {
            std::string plus = (addValue + minValue < 0) ? "" : "+";

            count++;
            if (HoverItem->Info->Type != ItemType::Gem)
            {
                std::string negative = "+";
                if (addValue < 0)
                {
                    negative = "";
                }
                text = StringHelper::formatSimple(addValue != 0 ? "A.Speed: " + plus + "{0} ({2}{1})" : "A.Speed: " + plus + "{0}", minValue + addValue, addValue, negative);
                //text = string.Format(addValue > 0 ? "A.Speed: + {0} (+{1})" : "A.Speed: + {0}", minValue + addValue, addValue);
            }
            else
            {
                text = StringHelper::formatSimple("Adds +{0} A.Speed", minValue + maxValue + addValue);
            }
            MirLabel *ASPEEDLabel = new MirLabel();
            ASPEEDLabel->setAutoSize(true);
            ASPEEDLabel->setForeColour(addValue > 0 ? Color::Cyan : Color::White);
            Point tempVar16(4, ItemLabel->getDisplayRectangle()->Bottom);
            ASPEEDLabel->setLocation(&tempVar16);
            ASPEEDLabel->setOutLine(true);
            ASPEEDLabel->setParent(ItemLabel);
            ASPEEDLabel->setText(text);

            Size tempVar17(std::max(ItemLabel->getSize()->Width, ASPEEDLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, ASPEEDLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar17);

            delete ASPEEDLabel;
        }

        #pragma endregion

        #pragma region FREEZING

        minValue = realItem->Stats[Stat::Freezing];
        maxValue = 0;
        addValue = (!hideAdded && (!HoverItem->Info->NeedIdentify || HoverItem->Identified)) ? HoverItem->AddedStats[Stat::Freezing] : 0;

        if (minValue > 0 || maxValue > 0 || addValue > 0)
        {
            count++;
            if (HoverItem->Info->Type != ItemType::Gem)
            {
                text = StringHelper::formatSimple(addValue > 0 ? "Freezing: + {0} (+{1})" : "Freezing: + {0}", minValue + addValue, addValue);
            }
            else
            {
                text = StringHelper::formatSimple("Adds +{0} Freezing", minValue + maxValue + addValue);
            }
            MirLabel *FREEZINGLabel = new MirLabel();
            FREEZINGLabel->setAutoSize(true);
            FREEZINGLabel->setForeColour(addValue > 0 ? Color::Cyan : Color::White);
            Point tempVar18(4, ItemLabel->getDisplayRectangle()->Bottom);
            FREEZINGLabel->setLocation(&tempVar18);
            FREEZINGLabel->setOutLine(true);
            FREEZINGLabel->setParent(ItemLabel);
            FREEZINGLabel->setText(text);

            Size tempVar19(std::max(ItemLabel->getSize()->Width, FREEZINGLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, FREEZINGLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar19);

            delete FREEZINGLabel;
        }

        #pragma endregion

        #pragma region POISON

        minValue = realItem->Stats[Stat::PoisonAttack];
        maxValue = 0;
        addValue = (!hideAdded && (!HoverItem->Info->NeedIdentify || HoverItem->Identified)) ? HoverItem->AddedStats[Stat::PoisonAttack] : 0;

        if (minValue > 0 || maxValue > 0 || addValue > 0)
        {
            count++;
            if (HoverItem->Info->Type != ItemType::Gem)
            {
                text = StringHelper::formatSimple(addValue > 0 ? "Poison: + {0} (+{1})" : "Poison: + {0}", minValue + addValue, addValue);
            }
            else
            {
                text = StringHelper::formatSimple("Adds +{0} Poison", minValue + maxValue + addValue);
            }
            MirLabel *POISONLabel = new MirLabel();
            POISONLabel->setAutoSize(true);
            POISONLabel->setForeColour(addValue > 0 ? Color::Cyan : Color::White);
            Point tempVar20(4, ItemLabel->getDisplayRectangle()->Bottom);
            POISONLabel->setLocation(&tempVar20);
            POISONLabel->setOutLine(true);
            POISONLabel->setParent(ItemLabel);
            POISONLabel->setText(text);

            Size tempVar21(std::max(ItemLabel->getSize()->Width, POISONLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, POISONLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar21);

            delete POISONLabel;
        }

        #pragma endregion

        #pragma region CRITICALRATE / FLEXIBILITY

        minValue = realItem->Stats[Stat::CriticalRate];
        maxValue = 0;
        addValue = (!hideAdded && (!HoverItem->Info->NeedIdentify || HoverItem->Identified)) ? HoverItem->AddedStats[Stat::CriticalRate] : 0;

        if ((minValue > 0 || maxValue > 0 || addValue > 0) && (realItem->Type != ItemType::Gem))
        {
            count++;
            MirLabel *CRITICALRATELabel = new MirLabel();
            CRITICALRATELabel->setAutoSize(true);
            CRITICALRATELabel->setForeColour(addValue > 0 ? Color::Cyan : Color::White);
            Point tempVar22(4, ItemLabel->getDisplayRectangle()->Bottom);
            CRITICALRATELabel->setLocation(&tempVar22);
            CRITICALRATELabel->setOutLine(true);
            CRITICALRATELabel->setParent(ItemLabel);
            CRITICALRATELabel->setText(StringHelper::formatSimple(addValue > 0 ? "Critical Chance: + {0} (+{1})" : "Critical Chance: + {0}", minValue + addValue, addValue));

            if (fishingItem)
            {
                CRITICALRATELabel->setText(StringHelper::formatSimple(addValue > 0 ? "Flexibility: + {0} (+{1})" : "Flexibility: + {0}", minValue + addValue, addValue));
            }

            Size tempVar23(std::max(ItemLabel->getSize()->Width, CRITICALRATELabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, CRITICALRATELabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar23);

            delete CRITICALRATELabel;
        }

        #pragma endregion

        #pragma region CRITICALDAMAGE

        minValue = realItem->Stats[Stat::CriticalDamage];
        maxValue = 0;
        addValue = (!hideAdded && (!HoverItem->Info->NeedIdentify || HoverItem->Identified)) ? HoverItem->AddedStats[Stat::CriticalDamage] : 0;

        if ((minValue > 0 || maxValue > 0 || addValue > 0) && (realItem->Type != ItemType::Gem))
        {
            count++;
            MirLabel *CRITICALDAMAGELabel = new MirLabel();
            CRITICALDAMAGELabel->setAutoSize(true);
            CRITICALDAMAGELabel->setForeColour(addValue > 0 ? Color::Cyan : Color::White);
            Point tempVar24(4, ItemLabel->getDisplayRectangle()->Bottom);
            CRITICALDAMAGELabel->setLocation(&tempVar24);
            CRITICALDAMAGELabel->setOutLine(true);
            CRITICALDAMAGELabel->setParent(ItemLabel);
            CRITICALDAMAGELabel->setText(StringHelper::formatSimple(addValue > 0 ? "Critical Damage: + {0} (+{1})" : "Critical Damage: + {0}", minValue + addValue, addValue));

            Size tempVar25(std::max(ItemLabel->getSize()->Width, CRITICALDAMAGELabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, CRITICALDAMAGELabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar25);

            delete CRITICALDAMAGELabel;
        }

        #pragma endregion

        #pragma region Reflect

        minValue = realItem->Stats[Stat::Reflect];
        maxValue = 0;
        addValue = 0;

        if ((minValue > 0 || maxValue > 0 || addValue > 0) && (realItem->Type != ItemType::Gem))
        {
            count++;
            MirLabel *ReflectLabel = new MirLabel();
            ReflectLabel->setAutoSize(true);
            ReflectLabel->setForeColour(addValue > 0 ? Color::Cyan : Color::White);
            Point tempVar26(4, ItemLabel->getDisplayRectangle()->Bottom);
            ReflectLabel->setLocation(&tempVar26);
            ReflectLabel->setOutLine(true);
            ReflectLabel->setParent(ItemLabel);
            ReflectLabel->setText(StringHelper::formatSimple("Reflect chance: {0}", minValue));

            Size tempVar27(std::max(ItemLabel->getSize()->Width, ReflectLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, ReflectLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar27);

            delete ReflectLabel;
        }

        #pragma endregion

        #pragma region Hpdrain

        minValue = realItem->Stats[Stat::HPDrainRatePercent];
        maxValue = 0;
        addValue = 0;

        if ((minValue > 0 || maxValue > 0 || addValue > 0) && (realItem->Type != ItemType::Gem))
        {
            count++;
            MirLabel *HPdrainLabel = new MirLabel();
            HPdrainLabel->setAutoSize(true);
            HPdrainLabel->setForeColour(addValue > 0 ? Color::Cyan : Color::White);
            Point tempVar28(4, ItemLabel->getDisplayRectangle()->Bottom);
            HPdrainLabel->setLocation(&tempVar28);
            HPdrainLabel->setOutLine(true);
            HPdrainLabel->setParent(ItemLabel);
            HPdrainLabel->setText(StringHelper::formatSimple("HP Drain Rate: {0}%", minValue));

            Size tempVar29(std::max(ItemLabel->getSize()->Width, HPdrainLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, HPdrainLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar29);

            delete HPdrainLabel;
        }

        #pragma endregion

        #pragma region Exp Rate

        minValue = realItem->Stats[Stat::ExpRatePercent];
        maxValue = 0;
        addValue = (!hideAdded && (!HoverItem->Info->NeedIdentify || HoverItem->Identified)) ? HoverItem->AddedStats[Stat::ExpRatePercent] : 0;

        if (minValue != 0 || maxValue != 0 || addValue != 0)
        {
            std::string plus = (addValue + minValue < 0) ? "" : "+";

            count++;
            std::string negative = "+";
            if (addValue < 0)
            {
                negative = "";
            }
            text = StringHelper::formatSimple(addValue != 0 ? "Exp Rate: " + plus + "{0}% ({2}{1}%)" : "Exp Rate: " + plus + "{0}%", minValue + addValue, addValue, negative);

            MirLabel *expRateLabel = new MirLabel();
            expRateLabel->setAutoSize(true);
            expRateLabel->setForeColour(addValue > 0 ? Color::Cyan : Color::White);
            Point tempVar30(4, ItemLabel->getDisplayRectangle()->Bottom);
            expRateLabel->setLocation(&tempVar30);
            expRateLabel->setOutLine(true);
            expRateLabel->setParent(ItemLabel);
            expRateLabel->setText(text);

            Size tempVar31(std::max(ItemLabel->getSize()->Width, expRateLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, expRateLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar31);

            delete expRateLabel;
        }

        #pragma endregion

        #pragma region Drop Rate

        minValue = realItem->Stats[Stat::ItemDropRatePercent];
        maxValue = 0;
        addValue = (!hideAdded && (!HoverItem->Info->NeedIdentify || HoverItem->Identified)) ? HoverItem->AddedStats[Stat::ItemDropRatePercent] : 0;

        if (minValue != 0 || maxValue != 0 || addValue != 0)
        {
            std::string plus = (addValue + minValue < 0) ? "" : "+";

            count++;
            std::string negative = "+";
            if (addValue < 0)
            {
                negative = "";
            }
            text = StringHelper::formatSimple(addValue != 0 ? "Drop Rate: " + plus + "{0}% ({2}{1}%)" : "Drop Rate: " + plus + "{0}%", minValue + addValue, addValue, negative);

            MirLabel *dropRateLabel = new MirLabel();
            dropRateLabel->setAutoSize(true);
            dropRateLabel->setForeColour(addValue > 0 ? Color::Cyan : Color::White);
            Point tempVar32(4, ItemLabel->getDisplayRectangle()->Bottom);
            dropRateLabel->setLocation(&tempVar32);
            dropRateLabel->setOutLine(true);
            dropRateLabel->setParent(ItemLabel);
            dropRateLabel->setText(text);

            Size tempVar33(std::max(ItemLabel->getSize()->Width, dropRateLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, dropRateLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar33);

            delete dropRateLabel;
        }

        #pragma endregion

        #pragma region Gold Rate

        minValue = realItem->Stats[Stat::GoldDropRatePercent];
        maxValue = 0;
        addValue = (!hideAdded && (!HoverItem->Info->NeedIdentify || HoverItem->Identified)) ? HoverItem->AddedStats[Stat::GoldDropRatePercent] : 0;

        if (minValue != 0 || maxValue != 0 || addValue != 0)
        {
            std::string plus = (addValue + minValue < 0) ? "" : "+";

            count++;
            std::string negative = "+";
            if (addValue < 0)
            {
                negative = "";
            }
            text = StringHelper::formatSimple(addValue != 0 ? "Gold Rate: " + plus + "{0}% ({2}{1}%)" : "Gold Rate: " + plus + "{0}%", minValue + addValue, addValue, negative);

            MirLabel *goldRateLabel = new MirLabel();
            goldRateLabel->setAutoSize(true);
            goldRateLabel->setForeColour(addValue > 0 ? Color::Cyan : Color::White);
            Point tempVar34(4, ItemLabel->getDisplayRectangle()->Bottom);
            goldRateLabel->setLocation(&tempVar34);
            goldRateLabel->setOutLine(true);
            goldRateLabel->setParent(ItemLabel);
            goldRateLabel->setText(text);

            Size tempVar35(std::max(ItemLabel->getSize()->Width, goldRateLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, goldRateLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar35);

            delete goldRateLabel;
        }

        #pragma endregion

        if (count > 0)
        {
            Size tempVar36(ItemLabel->getSize()->Width, ItemLabel->getSize()->Height + 4);
            ItemLabel->setSize(&tempVar36);

            #pragma region OUTLINE
            MirControl *outLine = new MirControl();
            outLine->setBackColour(Color::FromArgb(255, 50, 50, 50));
            outLine->setBorder(true);
            outLine->setBorderColour(Color::Gray);
            outLine->setNotControl(true);
            outLine->setParent(ItemLabel);
            outLine->setOpacity(0.4F);
            Point tempVar37(0, 0);
            outLine->setLocation(&tempVar37);
            outLine->setSize(ItemLabel->getSize());
            #pragma endregion

//C# TO C++ CONVERTER TODO TASK: A 'delete outLine' statement was not added since outLine was used in a 'return' or 'throw' statement.
            return outLine;
        }
        else
        {
            Size tempVar38(ItemLabel->getSize()->Width, ItemLabel->getSize()->Height - 4);
            ItemLabel->setSize(&tempVar38);
        }
        return nullptr;
    }

    MirControl *GameScene::DefenceInfoLabel(UserItem *item, bool Inspect, bool hideAdded)
    {
        unsigned short level = Inspect ? InspectDialog->Level : MapObject::User->Level;
        MirClass job = Inspect ? InspectDialog->Class : MapObject::User->Class;
        HoverItem = item;
        ItemInfo *realItem = Functions::GetRealItem(item->Info, level, job, ItemInfoList);

        Size tempVar(ItemLabel->getSize()->Width, ItemLabel->getSize()->Height + 4);
        ItemLabel->setSize(&tempVar);

        bool fishingItem = false;

        switch (HoverItem->Info->Type)
        {
            case ItemType::Hook:
            case ItemType::Float:
            case ItemType::Bait:
            case ItemType::Finder:
            case ItemType::Reel:
                fishingItem = true;
                break;
            case ItemType::Weapon:
                if (HoverItem->Info->Shape == 49 || HoverItem->Info->Shape == 50)
                {
                    fishingItem = true;
                }
                break;
            default:
                fishingItem = false;
                break;
        }

        int count = 0;
        int minValue = 0;
        int maxValue = 0;
        int addValue = 0;

        std::string text = "";
        #pragma region AC

        minValue = realItem->Stats[Stat::MinAC];
        maxValue = realItem->Stats[Stat::MaxAC];
        addValue = (!hideAdded && (!HoverItem->Info->NeedIdentify || HoverItem->Identified)) ? HoverItem->AddedStats[Stat::MaxAC] : 0;

        if (minValue > 0 || maxValue > 0 || addValue > 0)
        {
            count++;
            if (HoverItem->Info->Type != ItemType::Gem)
            {
                text = std::string::Format(addValue > 0 ? GameLanguage::AC : GameLanguage::AC2, minValue, maxValue + addValue, addValue);
            }
            else
            {
                text = StringHelper::formatSimple("Adds +{0} AC", minValue + maxValue + addValue);
            }
            MirLabel *ACLabel = new MirLabel();
            ACLabel->setAutoSize(true);
            ACLabel->setForeColour(addValue > 0 ? Color::Cyan : Color::White);
            Point tempVar2(4, ItemLabel->getDisplayRectangle()->Bottom);
            ACLabel->setLocation(&tempVar2);
            ACLabel->setOutLine(true);
            ACLabel->setParent(ItemLabel);
            ACLabel->setText(text);

            if (fishingItem)
            {
                if (HoverItem->Info->Type == ItemType::Float)
                {
                    ACLabel->setText(StringHelper::formatSimple("Nibble Chance + " + (addValue > 0 ? "{0}~{1}% (+{2})" : "{0}~{1}%"), minValue, maxValue + addValue));
                }
                else if (HoverItem->Info->Type == ItemType::Finder)
                {
                    ACLabel->setText(StringHelper::formatSimple("Finder Increase + " + (addValue > 0 ? "{0}~{1}% (+{2})" : "{0}~{1}%"), minValue, maxValue + addValue));
                }
                else
                {
                    ACLabel->setText(StringHelper::formatSimple("Success Chance + " + (addValue > 0 ? "{0}% (+{1})" : "{0}%"), maxValue, maxValue + addValue));
                }
            }

            Size tempVar3(std::max(ItemLabel->getSize()->Width, ACLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, ACLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar3);

            delete ACLabel;
        }

        #pragma endregion

        #pragma region MAC

        minValue = realItem->Stats[Stat::MinMAC];
        maxValue = realItem->Stats[Stat::MaxMAC];
        addValue = (!hideAdded && (!HoverItem->Info->NeedIdentify || HoverItem->Identified)) ? HoverItem->AddedStats[Stat::MaxMAC] : 0;

        if (minValue > 0 || maxValue > 0 || addValue > 0)
        {
            count++;
            if (HoverItem->Info->Type != ItemType::Gem)
            {
                text = std::string::Format(addValue > 0 ? GameLanguage::MAC : GameLanguage::MAC2, minValue, maxValue + addValue, addValue);
            }
            else
            {
                text = StringHelper::formatSimple("Adds +{0} MAC", minValue + maxValue + addValue);
            }
            MirLabel *MACLabel = new MirLabel();
            MACLabel->setAutoSize(true);
            MACLabel->setForeColour(addValue > 0 ? Color::Cyan : Color::White);
            Point tempVar4(4, ItemLabel->getDisplayRectangle()->Bottom);
            MACLabel->setLocation(&tempVar4);
            MACLabel->setOutLine(true);
            MACLabel->setParent(ItemLabel);
            MACLabel->setText(text);

            if (fishingItem)
            {
                MACLabel->setText(StringHelper::formatSimple("AutoReel Chance + {0}%", maxValue + addValue));
            }

            Size tempVar5(std::max(ItemLabel->getSize()->Width, MACLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, MACLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar5);

            delete MACLabel;
        }

        #pragma endregion

        #pragma region MAXHP

        minValue = realItem->Stats[Stat::HP];
        maxValue = 0;
        addValue = (!hideAdded && (!HoverItem->Info->NeedIdentify || HoverItem->Identified)) ? HoverItem->AddedStats[Stat::HP] : 0;

        if (minValue > 0 || maxValue > 0 || addValue > 0)
        {
            count++;
            MirLabel *MAXHPLabel = new MirLabel();
            MAXHPLabel->setAutoSize(true);
            MAXHPLabel->setForeColour(addValue > 0 ? Color::Cyan : Color::White);
            Point tempVar6(4, ItemLabel->getDisplayRectangle()->Bottom);
            MAXHPLabel->setLocation(&tempVar6);
            MAXHPLabel->setOutLine(true);
            MAXHPLabel->setParent(ItemLabel);
            MAXHPLabel->setText(StringHelper::formatSimple(addValue > 0 ? "Max HP + {0} (+{1})" : "Max HP + {0}", minValue + addValue, addValue));

            Size tempVar7(std::max(ItemLabel->getSize()->Width, MAXHPLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, MAXHPLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar7);

            delete MAXHPLabel;
        }

        #pragma endregion

        #pragma region MAXMP

        minValue = realItem->Stats[Stat::MP];
        maxValue = 0;
        addValue = (!hideAdded && (!HoverItem->Info->NeedIdentify || HoverItem->Identified)) ? HoverItem->AddedStats[Stat::MP] : 0;

        if (minValue > 0 || maxValue > 0 || addValue > 0)
        {
            count++;
            MirLabel *MAXMPLabel = new MirLabel();
            MAXMPLabel->setAutoSize(true);
            MAXMPLabel->setForeColour(addValue > 0 ? Color::Cyan : Color::White);
            Point tempVar8(4, ItemLabel->getDisplayRectangle()->Bottom);
            MAXMPLabel->setLocation(&tempVar8);
            MAXMPLabel->setOutLine(true);
            MAXMPLabel->setParent(ItemLabel);
            MAXMPLabel->setText(StringHelper::formatSimple(addValue > 0 ? "Max MP + {0} (+{1})" : "Max MP + {0}", minValue + addValue, addValue));

            Size tempVar9(std::max(ItemLabel->getSize()->Width, MAXMPLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, MAXMPLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar9);

            delete MAXMPLabel;
        }

        #pragma endregion

        #pragma region MAXHPRATE

        minValue = realItem->Stats[Stat::HPRatePercent];
        maxValue = 0;
        addValue = 0;

        if (minValue > 0 || maxValue > 0 || addValue > 0)
        {
            count++;
            MirLabel *MAXHPRATELabel = new MirLabel();
            MAXHPRATELabel->setAutoSize(true);
            MAXHPRATELabel->setForeColour(addValue > 0 ? Color::Cyan : Color::White);
            Point tempVar10(4, ItemLabel->getDisplayRectangle()->Bottom);
            MAXHPRATELabel->setLocation(&tempVar10);
            MAXHPRATELabel->setOutLine(true);
            MAXHPRATELabel->setParent(ItemLabel);
            MAXHPRATELabel->setText(StringHelper::formatSimple("Max HP + {0}%", minValue + addValue));

            Size tempVar11(std::max(ItemLabel->getSize()->Width, MAXHPRATELabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, MAXHPRATELabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar11);

            delete MAXHPRATELabel;
        }

        #pragma endregion

        #pragma region MAXMPRATE

        minValue = realItem->Stats[Stat::MPRatePercent];
        maxValue = 0;
        addValue = 0;

        if (minValue > 0 || maxValue > 0 || addValue > 0)
        {
            count++;
            MirLabel *MAXMPRATELabel = new MirLabel();
            MAXMPRATELabel->setAutoSize(true);
            MAXMPRATELabel->setForeColour(addValue > 0 ? Color::Cyan : Color::White);
            Point tempVar12(4, ItemLabel->getDisplayRectangle()->Bottom);
            MAXMPRATELabel->setLocation(&tempVar12);
            MAXMPRATELabel->setOutLine(true);
            MAXMPRATELabel->setParent(ItemLabel);
            MAXMPRATELabel->setText(StringHelper::formatSimple("Max MP + {0}%", minValue + addValue));

            Size tempVar13(std::max(ItemLabel->getSize()->Width, MAXMPRATELabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, MAXMPRATELabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar13);

            delete MAXMPRATELabel;
        }

        #pragma endregion

        #pragma region MAXACRATE

        minValue = realItem->Stats[Stat::MaxACRatePercent];
        maxValue = 0;
        addValue = 0;

        if (minValue > 0 || maxValue > 0 || addValue > 0)
        {
            count++;
            MirLabel *MAXACRATE = new MirLabel();
            MAXACRATE->setAutoSize(true);
            MAXACRATE->setForeColour(addValue > 0 ? Color::Cyan : Color::White);
            Point tempVar14(4, ItemLabel->getDisplayRectangle()->Bottom);
            MAXACRATE->setLocation(&tempVar14);
            MAXACRATE->setOutLine(true);
            MAXACRATE->setParent(ItemLabel);
            MAXACRATE->setText(StringHelper::formatSimple("Max AC + {0}%", minValue + addValue));

            Size tempVar15(std::max(ItemLabel->getSize()->Width, MAXACRATE->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, MAXACRATE->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar15);

            delete MAXACRATE;
        }

        #pragma endregion

        #pragma region MAXMACRATE

        minValue = realItem->Stats[Stat::MaxMACRatePercent];
        maxValue = 0;
        addValue = 0;

        if (minValue > 0 || maxValue > 0 || addValue > 0)
        {
            count++;
            MirLabel *MAXMACRATELabel = new MirLabel();
            MAXMACRATELabel->setAutoSize(true);
            MAXMACRATELabel->setForeColour(addValue > 0 ? Color::Cyan : Color::White);
            Point tempVar16(4, ItemLabel->getDisplayRectangle()->Bottom);
            MAXMACRATELabel->setLocation(&tempVar16);
            MAXMACRATELabel->setOutLine(true);
            MAXMACRATELabel->setParent(ItemLabel);
            MAXMACRATELabel->setText(StringHelper::formatSimple("Max MAC + {0}%", minValue + addValue));

            Size tempVar17(std::max(ItemLabel->getSize()->Width, MAXMACRATELabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, MAXMACRATELabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar17);

            delete MAXMACRATELabel;
        }

        #pragma endregion

        #pragma region HEALTH_RECOVERY

        minValue = realItem->Stats[Stat::HealthRecovery];
        maxValue = 0;
        addValue = (!hideAdded && (!HoverItem->Info->NeedIdentify || HoverItem->Identified)) ? HoverItem->AddedStats[Stat::HealthRecovery] : 0;

        if (minValue > 0 || maxValue > 0 || addValue > 0)
        {
            count++;
            MirLabel *HEALTH_RECOVERYLabel = new MirLabel();
            HEALTH_RECOVERYLabel->setAutoSize(true);
            HEALTH_RECOVERYLabel->setForeColour(addValue > 0 ? Color::Cyan : Color::White);
            Point tempVar18(4, ItemLabel->getDisplayRectangle()->Bottom);
            HEALTH_RECOVERYLabel->setLocation(&tempVar18);
            HEALTH_RECOVERYLabel->setOutLine(true);
            HEALTH_RECOVERYLabel->setParent(ItemLabel);
            HEALTH_RECOVERYLabel->setText(StringHelper::formatSimple(addValue > 0 ? "Health Recovery + {0} (+{1})" : "Health Recovery + {0}", minValue + addValue, addValue));

            Size tempVar19(std::max(ItemLabel->getSize()->Width, HEALTH_RECOVERYLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, HEALTH_RECOVERYLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar19);

            delete HEALTH_RECOVERYLabel;
        }

        #pragma endregion

        #pragma region MANA_RECOVERY

        minValue = realItem->Stats[Stat::SpellRecovery];
        maxValue = 0;
        addValue = (!hideAdded && (!HoverItem->Info->NeedIdentify || HoverItem->Identified)) ? HoverItem->AddedStats[Stat::SpellRecovery] : 0;

        if (minValue > 0 || maxValue > 0 || addValue > 0)
        {
            count++;
            MirLabel *MANA_RECOVERYLabel = new MirLabel();
            MANA_RECOVERYLabel->setAutoSize(true);
            MANA_RECOVERYLabel->setForeColour(addValue > 0 ? Color::Cyan : Color::White);
            Point tempVar20(4, ItemLabel->getDisplayRectangle()->Bottom);
            MANA_RECOVERYLabel->setLocation(&tempVar20);
            MANA_RECOVERYLabel->setOutLine(true);
            MANA_RECOVERYLabel->setParent(ItemLabel);
            MANA_RECOVERYLabel->setText(StringHelper::formatSimple(addValue > 0 ? "Mana Recovery + {0} (+{1})" : "Mana Recovery + {0}", minValue + addValue, addValue));

            Size tempVar21(std::max(ItemLabel->getSize()->Width, MANA_RECOVERYLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, MANA_RECOVERYLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar21);

            delete MANA_RECOVERYLabel;
        }

        #pragma endregion

        #pragma region POISON_RECOVERY

        minValue = realItem->Stats[Stat::PoisonRecovery];
        maxValue = 0;
        addValue = (!hideAdded && (!HoverItem->Info->NeedIdentify || HoverItem->Identified)) ? HoverItem->AddedStats[Stat::PoisonRecovery] : 0;

        if (minValue > 0 || maxValue > 0 || addValue > 0)
        {
            count++;
            MirLabel *POISON_RECOVERYabel = new MirLabel();
            POISON_RECOVERYabel->setAutoSize(true);
            POISON_RECOVERYabel->setForeColour(addValue > 0 ? Color::Cyan : Color::White);
            Point tempVar22(4, ItemLabel->getDisplayRectangle()->Bottom);
            POISON_RECOVERYabel->setLocation(&tempVar22);
            POISON_RECOVERYabel->setOutLine(true);
            POISON_RECOVERYabel->setParent(ItemLabel);
            POISON_RECOVERYabel->setText(StringHelper::formatSimple(addValue > 0 ? "Poison Recovery + {0} (+{1})" : "Poison Recovery + {0}", minValue + addValue, addValue));

            Size tempVar23(std::max(ItemLabel->getSize()->Width, POISON_RECOVERYabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, POISON_RECOVERYabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar23);

            delete POISON_RECOVERYabel;
        }

        #pragma endregion

        #pragma region AGILITY

        minValue = realItem->Stats[Stat::Agility];
        maxValue = 0;
        addValue = (!hideAdded && (!HoverItem->Info->NeedIdentify || HoverItem->Identified)) ? HoverItem->AddedStats[Stat::Agility] : 0;

        if (minValue > 0 || maxValue > 0 || addValue > 0)
        {
            count++;
            if (HoverItem->Info->Type != ItemType::Gem)
            {
                text = std::string::Format(addValue > 0 ? GameLanguage::Agility : GameLanguage::Agility2, minValue + addValue, addValue);
            }
            else
            {
                text = StringHelper::formatSimple("Adds +{0} Agility", minValue + maxValue + addValue);
            }

            MirLabel *AGILITYLabel = new MirLabel();
            AGILITYLabel->setAutoSize(true);
            AGILITYLabel->setForeColour(addValue > 0 ? Color::Cyan : Color::White);
            Point tempVar24(4, ItemLabel->getDisplayRectangle()->Bottom);
            AGILITYLabel->setLocation(&tempVar24);
            AGILITYLabel->setOutLine(true);
            AGILITYLabel->setParent(ItemLabel);
            AGILITYLabel->setText(text);

            Size tempVar25(std::max(ItemLabel->getSize()->Width, AGILITYLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, AGILITYLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar25);

            delete AGILITYLabel;
        }

        #pragma endregion

        #pragma region STRONG

        minValue = realItem->Stats[Stat::Strong];
        maxValue = 0;
        addValue = (!hideAdded && (!HoverItem->Info->NeedIdentify || HoverItem->Identified)) ? HoverItem->AddedStats[Stat::Strong] : 0;

        if (minValue > 0 || maxValue > 0 || addValue > 0)
        {
            count++;
            MirLabel *STRONGLabel = new MirLabel();
            STRONGLabel->setAutoSize(true);
            STRONGLabel->setForeColour(addValue > 0 ? Color::Cyan : Color::White);
            Point tempVar26(4, ItemLabel->getDisplayRectangle()->Bottom);
            STRONGLabel->setLocation(&tempVar26);
            STRONGLabel->setOutLine(true);
            STRONGLabel->setParent(ItemLabel);
            STRONGLabel->setText(StringHelper::formatSimple(addValue > 0 ? "Strong + {0} (+{1})" : "Strong + {0}", minValue + addValue, addValue));

            Size tempVar27(std::max(ItemLabel->getSize()->Width, STRONGLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, STRONGLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar27);

            delete STRONGLabel;
        }

        #pragma endregion

        #pragma region POISON_RESIST

        minValue = realItem->Stats[Stat::PoisonResist];
        maxValue = 0;
        addValue = (!hideAdded && (!HoverItem->Info->NeedIdentify || HoverItem->Identified)) ? HoverItem->AddedStats[Stat::PoisonResist] : 0;

        if (minValue > 0 || maxValue > 0 || addValue > 0)
        {
            count++;
            if (HoverItem->Info->Type != ItemType::Gem)
            {
                text = StringHelper::formatSimple(addValue > 0 ? "Poison Resist + {0} (+{1})" : "Poison Resist + {0}", minValue + addValue, addValue);
            }
            else
            {
                text = StringHelper::formatSimple("Adds +{0} Poison Resist", minValue + maxValue + addValue);
            }
            MirLabel *POISON_RESISTLabel = new MirLabel();
            POISON_RESISTLabel->setAutoSize(true);
            POISON_RESISTLabel->setForeColour(addValue > 0 ? Color::Cyan : Color::White);
            Point tempVar28(4, ItemLabel->getDisplayRectangle()->Bottom);
            POISON_RESISTLabel->setLocation(&tempVar28);
            POISON_RESISTLabel->setOutLine(true);
            POISON_RESISTLabel->setParent(ItemLabel);
            POISON_RESISTLabel->setText(text);

            Size tempVar29(std::max(ItemLabel->getSize()->Width, POISON_RESISTLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, POISON_RESISTLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar29);

            delete POISON_RESISTLabel;
        }

        #pragma endregion

        #pragma region MAGIC_RESIST

        minValue = realItem->Stats[Stat::MagicResist];
        maxValue = 0;
        addValue = (!hideAdded && (!HoverItem->Info->NeedIdentify || HoverItem->Identified)) ? HoverItem->AddedStats[Stat::MagicResist] : 0;

        if (minValue > 0 || maxValue > 0 || addValue > 0)
        {
            count++;
            if (HoverItem->Info->Type != ItemType::Gem)
            {
                text = StringHelper::formatSimple(addValue > 0 ? "Magic Resist + {0} (+{1})" : "Magic Resist + {0}", minValue + addValue, addValue);
            }
            else
            {
                text = StringHelper::formatSimple("Adds +{0} Magic Resist", minValue + maxValue + addValue);
            }
            MirLabel *MAGIC_RESISTLabel = new MirLabel();
            MAGIC_RESISTLabel->setAutoSize(true);
            MAGIC_RESISTLabel->setForeColour(addValue > 0 ? Color::Cyan : Color::White);
            Point tempVar30(4, ItemLabel->getDisplayRectangle()->Bottom);
            MAGIC_RESISTLabel->setLocation(&tempVar30);
            MAGIC_RESISTLabel->setOutLine(true);
            MAGIC_RESISTLabel->setParent(ItemLabel);
            MAGIC_RESISTLabel->setText(text);

            Size tempVar31(std::max(ItemLabel->getSize()->Width, MAGIC_RESISTLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, MAGIC_RESISTLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar31);

            delete MAGIC_RESISTLabel;
        }

        #pragma endregion

        if (count > 0)
        {
            Size tempVar32(ItemLabel->getSize()->Width, ItemLabel->getSize()->Height + 4);
            ItemLabel->setSize(&tempVar32);

            #pragma region OUTLINE
            MirControl *outLine = new MirControl();
            outLine->setBackColour(Color::FromArgb(255, 50, 50, 50));
            outLine->setBorder(true);
            outLine->setBorderColour(Color::Gray);
            outLine->setNotControl(true);
            outLine->setParent(ItemLabel);
            outLine->setOpacity(0.4F);
            Point tempVar33(0, 0);
            outLine->setLocation(&tempVar33);
            outLine->setSize(ItemLabel->getSize());
            #pragma endregion

//C# TO C++ CONVERTER TODO TASK: A 'delete outLine' statement was not added since outLine was used in a 'return' or 'throw' statement.
            return outLine;
        }
        else
        {
            Size tempVar34(ItemLabel->getSize()->Width, ItemLabel->getSize()->Height - 4);
            ItemLabel->setSize(&tempVar34);
        }
        return nullptr;
    }

    MirControl *GameScene::WeightInfoLabel(UserItem *item, bool Inspect)
    {
        unsigned short level = Inspect ? InspectDialog->Level : MapObject::User->Level;
        MirClass job = Inspect ? InspectDialog->Class : MapObject::User->Class;
        HoverItem = item;
        ItemInfo *realItem = Functions::GetRealItem(item->Info, level, job, ItemInfoList);

        Size tempVar(ItemLabel->getSize()->Width, ItemLabel->getSize()->Height + 4);
        ItemLabel->setSize(&tempVar);

        int count = 0;
        int minValue = 0;
        int maxValue = 0;
        int addValue = 0;

        #pragma region HANDWEIGHT

        minValue = realItem->Stats[Stat::HandWeight];
        maxValue = 0;
        addValue = 0;

        if (minValue > 0 || maxValue > 0 || addValue > 0)
        {
            count++;
            MirLabel *HANDWEIGHTLabel = new MirLabel();
            HANDWEIGHTLabel->setAutoSize(true);
            HANDWEIGHTLabel->setForeColour(addValue > 0 ? Color::Cyan : Color::White);
            Point tempVar2(4, ItemLabel->getDisplayRectangle()->Bottom);
            HANDWEIGHTLabel->setLocation(&tempVar2);
            HANDWEIGHTLabel->setOutLine(true);
            HANDWEIGHTLabel->setParent(ItemLabel);
            HANDWEIGHTLabel->setText(StringHelper::formatSimple(addValue > 0 ? "Hand Weight + {0} (+{1})" : "Hand Weight + {0}", minValue + addValue, addValue));

            Size tempVar3(std::max(ItemLabel->getSize()->Width, HANDWEIGHTLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, HANDWEIGHTLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar3);

            delete HANDWEIGHTLabel;
        }

        #pragma endregion

        #pragma region WEARWEIGHT

        minValue = realItem->Stats[Stat::WearWeight];
        maxValue = 0;
        addValue = 0;

        if (minValue > 0 || maxValue > 0 || addValue > 0)
        {
            count++;
            MirLabel *WEARWEIGHTLabel = new MirLabel();
            WEARWEIGHTLabel->setAutoSize(true);
            WEARWEIGHTLabel->setForeColour(addValue > 0 ? Color::Cyan : Color::White);
            Point tempVar4(4, ItemLabel->getDisplayRectangle()->Bottom);
            WEARWEIGHTLabel->setLocation(&tempVar4);
            WEARWEIGHTLabel->setOutLine(true);
            WEARWEIGHTLabel->setParent(ItemLabel);
            WEARWEIGHTLabel->setText(StringHelper::formatSimple(addValue > 0 ? "Wear Weight + {0} (+{1})" : "Wear Weight + {0}", minValue + addValue, addValue));

            Size tempVar5(std::max(ItemLabel->getSize()->Width, WEARWEIGHTLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, WEARWEIGHTLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar5);

            delete WEARWEIGHTLabel;
        }

        #pragma endregion

        #pragma region BAGWEIGHT

        minValue = realItem->Stats[Stat::BagWeight];
        maxValue = 0;
        addValue = 0;

        if (minValue > 0 || maxValue > 0 || addValue > 0)
        {
            count++;
            MirLabel *BAGWEIGHTLabel = new MirLabel();
            BAGWEIGHTLabel->setAutoSize(true);
            BAGWEIGHTLabel->setForeColour(addValue > 0 ? Color::Cyan : Color::White);
            Point tempVar6(4, ItemLabel->getDisplayRectangle()->Bottom);
            BAGWEIGHTLabel->setLocation(&tempVar6);
            BAGWEIGHTLabel->setOutLine(true);
            BAGWEIGHTLabel->setParent(ItemLabel);
            BAGWEIGHTLabel->setText(StringHelper::formatSimple(addValue > 0 ? "Bag Weight + {0} (+{1})" : "Bag Weight + {0}", minValue + addValue, addValue));

            Size tempVar7(std::max(ItemLabel->getSize()->Width, BAGWEIGHTLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, BAGWEIGHTLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar7);

            delete BAGWEIGHTLabel;
        }

        #pragma endregion

        #pragma region FASTRUN
        minValue = realItem->CanFastRun == true?1:0;
        maxValue = 0;
        addValue = 0;

        if (minValue > 0 || maxValue > 0 || addValue > 0)
        {
            count++;
            MirLabel *BAGWEIGHTLabel = new MirLabel();
            BAGWEIGHTLabel->setAutoSize(true);
            BAGWEIGHTLabel->setForeColour(addValue > 0 ? Color::Cyan : Color::White);
            Point tempVar8(4, ItemLabel->getDisplayRectangle()->Bottom);
            BAGWEIGHTLabel->setLocation(&tempVar8);
            BAGWEIGHTLabel->setOutLine(true);
            BAGWEIGHTLabel->setParent(ItemLabel);
            BAGWEIGHTLabel->setText(std::string::Format("Instant Run"));

            Size tempVar9(std::max(ItemLabel->getSize()->Width, BAGWEIGHTLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, BAGWEIGHTLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar9);

            delete BAGWEIGHTLabel;
        }

        #pragma endregion

        #pragma region TIME & RANGE
        minValue = 0;
        maxValue = 0;
        addValue = 0;

        if (HoverItem->Info->Type == ItemType::Potion && HoverItem->Info->Durability > 0)
        {
            count++;
            MirLabel *TNRLabel = new MirLabel();
            TNRLabel->setAutoSize(true);
            TNRLabel->setForeColour(addValue > 0 ? Color::Cyan : Color::White);
            Point tempVar10(4, ItemLabel->getDisplayRectangle()->Bottom);
            TNRLabel->setLocation(&tempVar10);
            TNRLabel->setOutLine(true);
            TNRLabel->setParent(ItemLabel);
            TNRLabel->setText(StringHelper::formatSimple("Time : {0}", Functions::PrintTimeSpanFromSeconds(HoverItem->Info->Durability * 60)));

            Size tempVar11(std::max(ItemLabel->getSize()->Width, TNRLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, TNRLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar11);

            delete TNRLabel;
        }

        if (HoverItem->Info->Type == ItemType::Transform && HoverItem->Info->Durability > 0)
        {
            count++;
            MirLabel *TNRLabel = new MirLabel();
            TNRLabel->setAutoSize(true);
            TNRLabel->setForeColour(addValue > 0 ? Color::Cyan : Color::White);
            Point tempVar12(4, ItemLabel->getDisplayRectangle()->Bottom);
            TNRLabel->setLocation(&tempVar12);
            TNRLabel->setOutLine(true);
            TNRLabel->setParent(ItemLabel);
            TNRLabel->setText(StringHelper::formatSimple("Time : {0}", Functions::PrintTimeSpanFromSeconds(HoverItem->Info->Durability, false)));

            Size tempVar13(std::max(ItemLabel->getSize()->Width, TNRLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, TNRLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar13);

            delete TNRLabel;
        }

        #pragma endregion

        if (count > 0)
        {
            Size tempVar14(ItemLabel->getSize()->Width, ItemLabel->getSize()->Height + 4);
            ItemLabel->setSize(&tempVar14);

            #pragma region OUTLINE
            MirControl *outLine = new MirControl();
            outLine->setBackColour(Color::FromArgb(255, 50, 50, 50));
            outLine->setBorder(true);
            outLine->setBorderColour(Color::Gray);
            outLine->setNotControl(true);
            outLine->setParent(ItemLabel);
            outLine->setOpacity(0.4F);
            Point tempVar15(0, 0);
            outLine->setLocation(&tempVar15);
            outLine->setSize(ItemLabel->getSize());
            #pragma endregion

//C# TO C++ CONVERTER TODO TASK: A 'delete outLine' statement was not added since outLine was used in a 'return' or 'throw' statement.
            return outLine;
        }
        else
        {
            Size tempVar16(ItemLabel->getSize()->Width, ItemLabel->getSize()->Height - 4);
            ItemLabel->setSize(&tempVar16);
        }
        return nullptr;
    }

    MirControl *GameScene::AwakeInfoLabel(UserItem *item, bool Inspect)
    {
        unsigned short level = Inspect ? InspectDialog->Level : MapObject::User->Level;
        MirClass job = Inspect ? InspectDialog->Class : MapObject::User->Class;
        HoverItem = item;
        ItemInfo *realItem = Functions::GetRealItem(item->Info, level, job, ItemInfoList);

        Size tempVar(ItemLabel->getSize()->Width, ItemLabel->getSize()->Height + 4);
        ItemLabel->setSize(&tempVar);

        int count = 0;

        #pragma region AWAKENAME
        if (HoverItem->Awake->GetAwakeLevel() > 0)
        {
            count++;
            MirLabel *AWAKENAMELabel = new MirLabel();
            AWAKENAMELabel->setAutoSize(true);
            AWAKENAMELabel->setForeColour(GradeNameColor(HoverItem->Info->Grade));
            Point tempVar2(4, ItemLabel->getDisplayRectangle()->Bottom);
            AWAKENAMELabel->setLocation(&tempVar2);
            AWAKENAMELabel->setOutLine(true);
            AWAKENAMELabel->setParent(ItemLabel);
//C# TO C++ CONVERTER TODO TASK: There is no C++ equivalent to 'ToString':
            AWAKENAMELabel->setText(StringHelper::formatSimple("{0} Awakening({1})", HoverItem->Awake->Type.ToString(), HoverItem->Awake->GetAwakeLevel()));

            Size tempVar3(std::max(ItemLabel->getSize()->Width, AWAKENAMELabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, AWAKENAMELabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar3);

            delete AWAKENAMELabel;
        }

        #pragma endregion

        #pragma region AWAKE_TOTAL_VALUE
        if (HoverItem->Awake->GetAwakeValue() > 0)
        {
            count++;
            MirLabel *AWAKE_TOTAL_VALUELabel = new MirLabel();
            AWAKE_TOTAL_VALUELabel->setAutoSize(true);
            AWAKE_TOTAL_VALUELabel->setForeColour(Color::White);
            Point tempVar4(4, ItemLabel->getDisplayRectangle()->Bottom);
            AWAKE_TOTAL_VALUELabel->setLocation(&tempVar4);
            AWAKE_TOTAL_VALUELabel->setOutLine(true);
            AWAKE_TOTAL_VALUELabel->setParent(ItemLabel);
//C# TO C++ CONVERTER TODO TASK: There is no C++ equivalent to 'ToString':
            AWAKE_TOTAL_VALUELabel->setText(StringHelper::formatSimple(realItem->Type != ItemType::Armour ? "{0} + {1}~{2}" : "MAX {0} + {1}", HoverItem->Awake->Type.ToString(), HoverItem->Awake->GetAwakeValue(), HoverItem->Awake->GetAwakeValue()));

            Size tempVar5(std::max(ItemLabel->getSize()->Width, AWAKE_TOTAL_VALUELabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, AWAKE_TOTAL_VALUELabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar5);

            delete AWAKE_TOTAL_VALUELabel;
        }

        #pragma endregion

        #pragma region AWAKE_LEVEL_VALUE
        if (HoverItem->Awake->GetAwakeLevel() > 0)
        {
            count++;
            for (int i = 0; i < HoverItem->Awake->GetAwakeLevel(); i++)
            {
                MirLabel *AWAKE_LEVEL_VALUELabel = new MirLabel();
                AWAKE_LEVEL_VALUELabel->setAutoSize(true);
                AWAKE_LEVEL_VALUELabel->setForeColour(Color::White);
                Point tempVar6(4, ItemLabel->getDisplayRectangle()->Bottom);
                AWAKE_LEVEL_VALUELabel->setLocation(&tempVar6);
                AWAKE_LEVEL_VALUELabel->setOutLine(true);
                AWAKE_LEVEL_VALUELabel->setParent(ItemLabel);
//C# TO C++ CONVERTER TODO TASK: There is no C++ equivalent to 'ToString':
                AWAKE_LEVEL_VALUELabel->setText(std::string::Format(realItem->Type != ItemType::Armour ? "Level {0} : {1} + {2}~{3}" : "Level {0} : MAX {1} + {2}~{3}", i + 1, HoverItem->Awake->Type.ToString(), HoverItem->Awake->GetAwakeLevelValue(i), HoverItem->Awake->GetAwakeLevelValue(i)));

                Size tempVar7(std::max(ItemLabel->getSize()->Width, AWAKE_LEVEL_VALUELabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, AWAKE_LEVEL_VALUELabel->getDisplayRectangle()->Bottom));
                ItemLabel->setSize(&tempVar7);

                delete AWAKE_LEVEL_VALUELabel;
            }
        }

        #pragma endregion

        if (count > 0)
        {
            Size tempVar8(ItemLabel->getSize()->Width, ItemLabel->getSize()->Height + 4);
            ItemLabel->setSize(&tempVar8);

            #pragma region OUTLINE
            MirControl *outLine = new MirControl();
            outLine->setBackColour(Color::FromArgb(255, 50, 50, 50));
            outLine->setBorder(true);
            outLine->setBorderColour(Color::Gray);
            outLine->setNotControl(true);
            outLine->setParent(ItemLabel);
            outLine->setOpacity(0.4F);
            Point tempVar9(0, 0);
            outLine->setLocation(&tempVar9);
            outLine->setSize(ItemLabel->getSize());
            #pragma endregion

//C# TO C++ CONVERTER TODO TASK: A 'delete outLine' statement was not added since outLine was used in a 'return' or 'throw' statement.
            return outLine;
        }
        else
        {
            Size tempVar10(ItemLabel->getSize()->Width, ItemLabel->getSize()->Height - 4);
            ItemLabel->setSize(&tempVar10);
        }
        return nullptr;
    }

    MirControl *GameScene::SocketInfoLabel(UserItem *item, bool Inspect)
    {
        unsigned short level = Inspect ? InspectDialog->Level : MapObject::User->Level;
        MirClass job = Inspect ? InspectDialog->Class : MapObject::User->Class;
        HoverItem = item;
        ItemInfo *realItem = Functions::GetRealItem(item->Info, level, job, ItemInfoList);

        Size tempVar(ItemLabel->getSize()->Width, ItemLabel->getSize()->Height + 4);
        ItemLabel->setSize(&tempVar);


        int count = 0;

        #pragma region SOCKET

        for (int i = 0; i < item->Slots.size(); i++)
        {
            count++;
            MirLabel *SOCKETLabel = new MirLabel();
            SOCKETLabel->setAutoSize(true);
            SOCKETLabel->setForeColour((count > realItem->Slots && !realItem->isFishingRod() && realItem->Type != ItemType::Mount) ? Color::Cyan : Color::White);
            Point tempVar2(4, ItemLabel->getDisplayRectangle()->Bottom);
            SOCKETLabel->setLocation(&tempVar2);
            SOCKETLabel->setOutLine(true);
            SOCKETLabel->setParent(ItemLabel);
            SOCKETLabel->setText(StringHelper::formatSimple("Socket : {0}", item->Slots[i] == nullptr ? "Empty" : item->Slots[i]->getFriendlyName()));

            Size tempVar3(std::max(ItemLabel->getSize()->Width, SOCKETLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, SOCKETLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar3);

            delete SOCKETLabel;
        }

        #pragma endregion

        if (count > 0)
        {
            #pragma region SOCKET

            count++;
            MirLabel *SOCKETLabel = new MirLabel();
            SOCKETLabel->setAutoSize(true);
            SOCKETLabel->setForeColour(Color::White);
            Point tempVar4(4, ItemLabel->getDisplayRectangle()->Bottom);
            SOCKETLabel->setLocation(&tempVar4);
            SOCKETLabel->setOutLine(true);
            SOCKETLabel->setParent(ItemLabel);
            SOCKETLabel->setText("Ctrl + Right Click To Open Sockets");

            Size tempVar5(std::max(ItemLabel->getSize()->Width, SOCKETLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, SOCKETLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar5);

            #pragma endregion

            Size tempVar6(ItemLabel->getSize()->Width, ItemLabel->getSize()->Height + 4);
            ItemLabel->setSize(&tempVar6);

            #pragma region OUTLINE
            MirControl *outLine = new MirControl();
            outLine->setBackColour(Color::FromArgb(255, 50, 50, 50));
            outLine->setBorder(true);
            outLine->setBorderColour(Color::Gray);
            outLine->setNotControl(true);
            outLine->setParent(ItemLabel);
            outLine->setOpacity(0.4F);
            Point tempVar7(0, 0);
            outLine->setLocation(&tempVar7);
            outLine->setSize(ItemLabel->getSize());
            #pragma endregion

//C# TO C++ CONVERTER TODO TASK: A 'delete outLine' statement was not added since outLine was used in a 'return' or 'throw' statement.
            delete SOCKETLabel;
            return outLine;
        }
        else
        {
            Size tempVar8(ItemLabel->getSize()->Width, ItemLabel->getSize()->Height - 4);
            ItemLabel->setSize(&tempVar8);
        }
        return nullptr;
    }

    MirControl *GameScene::NeedInfoLabel(UserItem *item, bool Inspect)
    {
        unsigned short level = Inspect ? InspectDialog->Level : MapObject::User->Level;
        MirClass job = Inspect ? InspectDialog->Class : MapObject::User->Class;
        HoverItem = item;
        ItemInfo *realItem = Functions::GetRealItem(item->Info, level, job, ItemInfoList);

        Size tempVar(ItemLabel->getSize()->Width, ItemLabel->getSize()->Height + 4);
        ItemLabel->setSize(&tempVar);

        int count = 0;

        #pragma region LEVEL
        if (realItem->RequiredAmount > 0)
        {
            count++;
            std::string text;
            Color *colour = Color::White;
            switch (realItem->RequiredType)
            {
                case RequiredType::Level:
                    text = std::string::Format(GameLanguage::RequiredLevel, realItem->RequiredAmount);
                    if (MapObject::User->Level < realItem->RequiredAmount)
                    {
                        colour = Color::Red;
                    }
                    break;
                case RequiredType::MaxAC:
                    text = StringHelper::formatSimple("Required AC : {0}", realItem->RequiredAmount);
                    if (MapObject::User->Stats[Stat::MaxAC] < realItem->RequiredAmount)
                    {
                        colour = Color::Red;
                    }
                    break;
                case RequiredType::MaxMAC:
                    text = StringHelper::formatSimple("Required MAC : {0}", realItem->RequiredAmount);
                    if (MapObject::User->Stats[Stat::MaxMAC] < realItem->RequiredAmount)
                    {
                        colour = Color::Red;
                    }
                    break;
                case RequiredType::MaxDC:
                    text = std::string::Format(GameLanguage::RequiredDC, realItem->RequiredAmount);
                    if (MapObject::User->Stats[Stat::MaxDC] < realItem->RequiredAmount)
                    {
                        colour = Color::Red;
                    }
                    break;
                case RequiredType::MaxMC:
                    text = std::string::Format(GameLanguage::RequiredMC, realItem->RequiredAmount);
                    if (MapObject::User->Stats[Stat::MaxMC] < realItem->RequiredAmount)
                    {
                        colour = Color::Red;
                    }
                    break;
                case RequiredType::MaxSC:
                    text = std::string::Format(GameLanguage::RequiredSC, realItem->RequiredAmount);
                    if (MapObject::User->Stats[Stat::MaxSC] < realItem->RequiredAmount)
                    {
                        colour = Color::Red;
                    }
                    break;
                case RequiredType::MaxLevel:
                    text = StringHelper::formatSimple("Maximum Level : {0}", realItem->RequiredAmount);
                    if (MapObject::User->Level > realItem->RequiredAmount)
                    {
                        colour = Color::Red;
                    }
                    break;
                case RequiredType::MinAC:
                    text = StringHelper::formatSimple("Required Base AC : {0}", realItem->RequiredAmount);
                    if (MapObject::User->Stats[Stat::MinAC] < realItem->RequiredAmount)
                    {
                        colour = Color::Red;
                    }
                    break;
                case RequiredType::MinMAC:
                    text = StringHelper::formatSimple("Required Base MAC : {0}", realItem->RequiredAmount);
                    if (MapObject::User->Stats[Stat::MinMAC] < realItem->RequiredAmount)
                    {
                        colour = Color::Red;
                    }
                    break;
                case RequiredType::MinDC:
                    text = StringHelper::formatSimple("Required Base DC : {0}", realItem->RequiredAmount);
                    if (MapObject::User->Stats[Stat::MinDC] < realItem->RequiredAmount)
                    {
                        colour = Color::Red;
                    }
                    break;
                case RequiredType::MinMC:
                    text = StringHelper::formatSimple("Required Base MC : {0}", realItem->RequiredAmount);
                    if (MapObject::User->Stats[Stat::MinMC] < realItem->RequiredAmount)
                    {
                        colour = Color::Red;
                    }
                    break;
                case RequiredType::MinSC:
                    text = StringHelper::formatSimple("Required Base SC : {0}", realItem->RequiredAmount);
                    if (MapObject::User->Stats[Stat::MinSC] < realItem->RequiredAmount)
                    {
                        colour = Color::Red;
                    }
                    break;
                default:
                    text = "Unknown Type Required";
                    break;
            }

            MirLabel *LEVELLabel = new MirLabel();
            LEVELLabel->setAutoSize(true);
            LEVELLabel->setForeColour(colour);
            Point tempVar2(4, ItemLabel->getDisplayRectangle()->Bottom);
            LEVELLabel->setLocation(&tempVar2);
            LEVELLabel->setOutLine(true);
            LEVELLabel->setParent(ItemLabel);
            LEVELLabel->setText(text);

            Size tempVar3(std::max(ItemLabel->getSize()->Width, LEVELLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, LEVELLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar3);

            delete LEVELLabel;
        }

        #pragma endregion

        #pragma region CLASS
        if (realItem->RequiredClass != RequiredClass::None)
        {
            count++;
            Color *colour = Color::White;

            switch (MapObject::User->Class)
            {
                case MirClass::Warrior:
                    if (!realItem->RequiredClass::HasFlag(RequiredClass::Warrior))
                    {
                        colour = Color::Red;
                    }
                    break;
                case MirClass::Wizard:
                    if (!realItem->RequiredClass::HasFlag(RequiredClass::Wizard))
                    {
                        colour = Color::Red;
                    }
                    break;
                case MirClass::Taoist:
                    if (!realItem->RequiredClass::HasFlag(RequiredClass::Taoist))
                    {
                        colour = Color::Red;
                    }
                    break;
                case MirClass::Assassin:
                    if (!realItem->RequiredClass::HasFlag(RequiredClass::Assassin))
                    {
                        colour = Color::Red;
                    }
                    break;
                case MirClass::Archer:
                    if (!realItem->RequiredClass::HasFlag(RequiredClass::Archer))
                    {
                        colour = Color::Red;
                    }
                    break;
            }

            MirLabel *CLASSLabel = new MirLabel();
            CLASSLabel->setAutoSize(true);
            CLASSLabel->setForeColour(colour);
            Point tempVar4(4, ItemLabel->getDisplayRectangle()->Bottom);
            CLASSLabel->setLocation(&tempVar4);
            CLASSLabel->setOutLine(true);
            CLASSLabel->setParent(ItemLabel);
            CLASSLabel->setText(std::string::Format(GameLanguage::ClassRequired, realItem->RequiredClass));

            Size tempVar5(std::max(ItemLabel->getSize()->Width, CLASSLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, CLASSLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar5);

            delete CLASSLabel;
        }

        #pragma endregion

        if (count > 0)
        {
            Size tempVar6(ItemLabel->getSize()->Width, ItemLabel->getSize()->Height + 4);
            ItemLabel->setSize(&tempVar6);

            #pragma region OUTLINE
            MirControl *outLine = new MirControl();
            outLine->setBackColour(Color::FromArgb(255, 50, 50, 50));
            outLine->setBorder(true);
            outLine->setBorderColour(Color::Gray);
            outLine->setNotControl(true);
            outLine->setParent(ItemLabel);
            outLine->setOpacity(0.4F);
            Point tempVar7(0, 0);
            outLine->setLocation(&tempVar7);
            outLine->setSize(ItemLabel->getSize());
            #pragma endregion

//C# TO C++ CONVERTER TODO TASK: A 'delete outLine' statement was not added since outLine was used in a 'return' or 'throw' statement.
            return outLine;
        }
        else
        {
            Size tempVar8(ItemLabel->getSize()->Width, ItemLabel->getSize()->Height - 4);
            ItemLabel->setSize(&tempVar8);
        }
        return nullptr;
    }

    MirControl *GameScene::BindInfoLabel(UserItem *item, bool Inspect, bool hideAdded)
    {
        unsigned short level = Inspect ? InspectDialog->Level : MapObject::User->Level;
        MirClass job = Inspect ? InspectDialog->Class : MapObject::User->Class;
        HoverItem = item;
        ItemInfo *realItem = Functions::GetRealItem(item->Info, level, job, ItemInfoList);

        Size tempVar(ItemLabel->getSize()->Width, ItemLabel->getSize()->Height + 4);
        ItemLabel->setSize(&tempVar);

        int count = 0;

        #pragma region DONT_DEATH_DROP

        if (HoverItem->Info->Bind != BindMode::None && HoverItem->Info->Bind::HasFlag(BindMode::DontDeathdrop))
        {
            count++;
            MirLabel *DONT_DEATH_DROPLabel = new MirLabel();
            DONT_DEATH_DROPLabel->setAutoSize(true);
            DONT_DEATH_DROPLabel->setForeColour(Color::Yellow);
            Point tempVar2(4, ItemLabel->getDisplayRectangle()->Bottom);
            DONT_DEATH_DROPLabel->setLocation(&tempVar2);
            DONT_DEATH_DROPLabel->setOutLine(true);
            DONT_DEATH_DROPLabel->setParent(ItemLabel);
            DONT_DEATH_DROPLabel->setText(std::string::Format("Can't drop on death"));

            Size tempVar3(std::max(ItemLabel->getSize()->Width, DONT_DEATH_DROPLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, DONT_DEATH_DROPLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar3);

            delete DONT_DEATH_DROPLabel;
        }

        #pragma endregion

        #pragma region DONT_DROP

        if (HoverItem->Info->Bind != BindMode::None && HoverItem->Info->Bind::HasFlag(BindMode::DontDrop))
        {
            count++;
            MirLabel *DONT_DROPLabel = new MirLabel();
            DONT_DROPLabel->setAutoSize(true);
            DONT_DROPLabel->setForeColour(Color::Yellow);
            Point tempVar4(4, ItemLabel->getDisplayRectangle()->Bottom);
            DONT_DROPLabel->setLocation(&tempVar4);
            DONT_DROPLabel->setOutLine(true);
            DONT_DROPLabel->setParent(ItemLabel);
            DONT_DROPLabel->setText(std::string::Format("Can't drop"));

            Size tempVar5(std::max(ItemLabel->getSize()->Width, DONT_DROPLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, DONT_DROPLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar5);

            delete DONT_DROPLabel;
        }

        #pragma endregion

        #pragma region DONT_UPGRADE

        if (HoverItem->Info->Bind != BindMode::None && HoverItem->Info->Bind::HasFlag(BindMode::DontUpgrade))
        {
            count++;
            MirLabel *DONT_UPGRADELabel = new MirLabel();
            DONT_UPGRADELabel->setAutoSize(true);
            DONT_UPGRADELabel->setForeColour(Color::Yellow);
            Point tempVar6(4, ItemLabel->getDisplayRectangle()->Bottom);
            DONT_UPGRADELabel->setLocation(&tempVar6);
            DONT_UPGRADELabel->setOutLine(true);
            DONT_UPGRADELabel->setParent(ItemLabel);
            DONT_UPGRADELabel->setText(std::string::Format("Can't upgrade"));

            Size tempVar7(std::max(ItemLabel->getSize()->Width, DONT_UPGRADELabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, DONT_UPGRADELabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar7);

            delete DONT_UPGRADELabel;
        }

        #pragma endregion

        #pragma region DONT_SELL

        if (HoverItem->Info->Bind != BindMode::None && HoverItem->Info->Bind::HasFlag(BindMode::DontSell))
        {
            count++;
            MirLabel *DONT_SELLLabel = new MirLabel();
            DONT_SELLLabel->setAutoSize(true);
            DONT_SELLLabel->setForeColour(Color::Yellow);
            Point tempVar8(4, ItemLabel->getDisplayRectangle()->Bottom);
            DONT_SELLLabel->setLocation(&tempVar8);
            DONT_SELLLabel->setOutLine(true);
            DONT_SELLLabel->setParent(ItemLabel);
            DONT_SELLLabel->setText(std::string::Format("Can't sell"));

            Size tempVar9(std::max(ItemLabel->getSize()->Width, DONT_SELLLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, DONT_SELLLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar9);

            delete DONT_SELLLabel;
        }

        #pragma endregion

        #pragma region DONT_TRADE

        if (HoverItem->Info->Bind != BindMode::None && HoverItem->Info->Bind::HasFlag(BindMode::DontTrade))
        {
            count++;
            MirLabel *DONT_TRADELabel = new MirLabel();
            DONT_TRADELabel->setAutoSize(true);
            DONT_TRADELabel->setForeColour(Color::Yellow);
            Point tempVar10(4, ItemLabel->getDisplayRectangle()->Bottom);
            DONT_TRADELabel->setLocation(&tempVar10);
            DONT_TRADELabel->setOutLine(true);
            DONT_TRADELabel->setParent(ItemLabel);
            DONT_TRADELabel->setText(std::string::Format("Can't trade"));

            Size tempVar11(std::max(ItemLabel->getSize()->Width, DONT_TRADELabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, DONT_TRADELabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar11);

            delete DONT_TRADELabel;
        }

        #pragma endregion

        #pragma region DONT_STORE

        if (HoverItem->Info->Bind != BindMode::None && HoverItem->Info->Bind::HasFlag(BindMode::DontStore))
        {
            count++;
            MirLabel *DONT_STORELabel = new MirLabel();
            DONT_STORELabel->setAutoSize(true);
            DONT_STORELabel->setForeColour(Color::Yellow);
            Point tempVar12(4, ItemLabel->getDisplayRectangle()->Bottom);
            DONT_STORELabel->setLocation(&tempVar12);
            DONT_STORELabel->setOutLine(true);
            DONT_STORELabel->setParent(ItemLabel);
            DONT_STORELabel->setText(std::string::Format("Can't store"));

            Size tempVar13(std::max(ItemLabel->getSize()->Width, DONT_STORELabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, DONT_STORELabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar13);

            delete DONT_STORELabel;
        }

        #pragma endregion

        #pragma region DONT_REPAIR

        if (HoverItem->Info->Bind != BindMode::None && HoverItem->Info->Bind::HasFlag(BindMode::DontRepair))
        {
            count++;
            MirLabel *DONT_REPAIRLabel = new MirLabel();
            DONT_REPAIRLabel->setAutoSize(true);
            DONT_REPAIRLabel->setForeColour(Color::Yellow);
            Point tempVar14(4, ItemLabel->getDisplayRectangle()->Bottom);
            DONT_REPAIRLabel->setLocation(&tempVar14);
            DONT_REPAIRLabel->setOutLine(true);
            DONT_REPAIRLabel->setParent(ItemLabel);
            DONT_REPAIRLabel->setText(std::string::Format("Can't repair"));

            Size tempVar15(std::max(ItemLabel->getSize()->Width, DONT_REPAIRLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, DONT_REPAIRLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar15);

            delete DONT_REPAIRLabel;
        }

        #pragma endregion

        #pragma region DONT_SPECIALREPAIR

        if (HoverItem->Info->Bind != BindMode::None && HoverItem->Info->Bind::HasFlag(BindMode::NoSRepair))
        {
            count++;
            MirLabel *DONT_REPAIRLabel = new MirLabel();
            DONT_REPAIRLabel->setAutoSize(true);
            DONT_REPAIRLabel->setForeColour(Color::Yellow);
            Point tempVar16(4, ItemLabel->getDisplayRectangle()->Bottom);
            DONT_REPAIRLabel->setLocation(&tempVar16);
            DONT_REPAIRLabel->setOutLine(true);
            DONT_REPAIRLabel->setParent(ItemLabel);
            DONT_REPAIRLabel->setText(std::string::Format("Can't special repair"));

            Size tempVar17(std::max(ItemLabel->getSize()->Width, DONT_REPAIRLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, DONT_REPAIRLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar17);

            delete DONT_REPAIRLabel;
        }

        #pragma endregion

        #pragma region BREAK_ON_DEATH

        if (HoverItem->Info->Bind != BindMode::None && HoverItem->Info->Bind::HasFlag(BindMode::BreakOnDeath))
        {
            count++;
            MirLabel *DONT_REPAIRLabel = new MirLabel();
            DONT_REPAIRLabel->setAutoSize(true);
            DONT_REPAIRLabel->setForeColour(Color::Yellow);
            Point tempVar18(4, ItemLabel->getDisplayRectangle()->Bottom);
            DONT_REPAIRLabel->setLocation(&tempVar18);
            DONT_REPAIRLabel->setOutLine(true);
            DONT_REPAIRLabel->setParent(ItemLabel);
            DONT_REPAIRLabel->setText(std::string::Format("Breaks on death"));

            Size tempVar19(std::max(ItemLabel->getSize()->Width, DONT_REPAIRLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, DONT_REPAIRLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar19);

            delete DONT_REPAIRLabel;
        }

        #pragma endregion

        #pragma region DONT_DESTROY_ON_DROP

        if (HoverItem->Info->Bind != BindMode::None && HoverItem->Info->Bind::HasFlag(BindMode::DestroyOnDrop))
        {
            count++;
            MirLabel *DONT_DODLabel = new MirLabel();
            DONT_DODLabel->setAutoSize(true);
            DONT_DODLabel->setForeColour(Color::Yellow);
            Point tempVar20(4, ItemLabel->getDisplayRectangle()->Bottom);
            DONT_DODLabel->setLocation(&tempVar20);
            DONT_DODLabel->setOutLine(true);
            DONT_DODLabel->setParent(ItemLabel);
            DONT_DODLabel->setText(std::string::Format("Destroyed when dropped"));

            Size tempVar21(std::max(ItemLabel->getSize()->Width, DONT_DODLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, DONT_DODLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar21);

            delete DONT_DODLabel;
        }

        #pragma endregion

        #pragma region NoWeddingRing

        if (HoverItem->Info->Bind != BindMode::None && HoverItem->Info->Bind::HasFlag(BindMode::NoWeddingRing))
        {
            count++;
            MirLabel *No_WedLabel = new MirLabel();
            No_WedLabel->setAutoSize(true);
            No_WedLabel->setForeColour(Color::Yellow);
            Point tempVar22(4, ItemLabel->getDisplayRectangle()->Bottom);
            No_WedLabel->setLocation(&tempVar22);
            No_WedLabel->setOutLine(true);
            No_WedLabel->setParent(ItemLabel);
            No_WedLabel->setText(std::string::Format("Cannot be a weddingring"));

            Size tempVar23(std::max(ItemLabel->getSize()->Width, No_WedLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, No_WedLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar23);

            delete No_WedLabel;
        }

        #pragma endregion

        #pragma region BIND_ON_EQUIP

        if ((HoverItem->Info->Bind::HasFlag(BindMode::BindOnEquip)) & HoverItem->SoulBoundId == -1)
        {
            count++;
            MirLabel *BOELabel = new MirLabel();
            BOELabel->setAutoSize(true);
            BOELabel->setForeColour(Color::Yellow);
            Point tempVar24(4, ItemLabel->getDisplayRectangle()->Bottom);
            BOELabel->setLocation(&tempVar24);
            BOELabel->setOutLine(true);
            BOELabel->setParent(ItemLabel);
            BOELabel->setText(std::string::Format("Soulbinds on equip"));

            Size tempVar25(std::max(ItemLabel->getSize()->Width, BOELabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, BOELabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar25);

            delete BOELabel;
        }
        else if (HoverItem->SoulBoundId != -1)
        {
            count++;
            MirLabel *BOELabel = new MirLabel();
            BOELabel->setAutoSize(true);
            BOELabel->setForeColour(Color::Yellow);
            Point tempVar26(4, ItemLabel->getDisplayRectangle()->Bottom);
            BOELabel->setLocation(&tempVar26);
            BOELabel->setOutLine(true);
            BOELabel->setParent(ItemLabel);
            BOELabel->setText("Soulbound to: " + GetUserName(static_cast<unsigned int>(HoverItem->SoulBoundId)));

            Size tempVar27(std::max(ItemLabel->getSize()->Width, BOELabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, BOELabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar27);

            delete BOELabel;
        }

        #pragma endregion

        #pragma region CURSED

        if ((!hideAdded && (!HoverItem->Info->NeedIdentify || HoverItem->Identified)) && HoverItem->Cursed)
        {
            count++;
            MirLabel *CURSEDLabel = new MirLabel();
            CURSEDLabel->setAutoSize(true);
            CURSEDLabel->setForeColour(Color::Yellow);
            Point tempVar28(4, ItemLabel->getDisplayRectangle()->Bottom);
            CURSEDLabel->setLocation(&tempVar28);
            CURSEDLabel->setOutLine(true);
            CURSEDLabel->setParent(ItemLabel);
            CURSEDLabel->setText(std::string::Format("Cursed"));

            Size tempVar29(std::max(ItemLabel->getSize()->Width, CURSEDLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, CURSEDLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar29);

            delete CURSEDLabel;
        }

        #pragma endregion

        #pragma region Gems

        if (HoverItem->Info->Type == ItemType::Gem)
        {
            #pragma region UseOn text
            count++;
            std::string Text = "";
            if (HoverItem->Info->Unique == SpecialItemMode::None)
            {
                Text = "Cannot be used on any item.";
            }
            else
            {
                Text = "Can be used on: ";
            }
            MirLabel *GemUseOn = new MirLabel();
            GemUseOn->setAutoSize(true);
            GemUseOn->setForeColour(Color::Yellow);
            Point tempVar30(4, ItemLabel->getDisplayRectangle()->Bottom);
            GemUseOn->setLocation(&tempVar30);
            GemUseOn->setOutLine(true);
            GemUseOn->setParent(ItemLabel);
            GemUseOn->setText(Text);

            Size tempVar31(std::max(ItemLabel->getSize()->Width, GemUseOn->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, GemUseOn->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar31);
            #pragma endregion
            #pragma region Weapon text
            count++;
            if (HoverItem->Info->Unique::HasFlag(SpecialItemMode::Paralize))
            {
                MirLabel *GemWeapon = new MirLabel();
                GemWeapon->setAutoSize(true);
                GemWeapon->setForeColour(Color::White);
                Point tempVar32(4, ItemLabel->getDisplayRectangle()->Bottom);
                GemWeapon->setLocation(&tempVar32);
                GemWeapon->setOutLine(true);
                GemWeapon->setParent(ItemLabel);
                GemWeapon->setText("-Weapon");

                Size tempVar33(std::max(ItemLabel->getSize()->Width, GemWeapon->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, GemWeapon->getDisplayRectangle()->Bottom));
                ItemLabel->setSize(&tempVar33);

                delete GemWeapon;
            }
            #pragma endregion
            #pragma region Armour text
            count++;
            if (HoverItem->Info->Unique::HasFlag(SpecialItemMode::Teleport))
            {
                MirLabel *GemArmour = new MirLabel();
                GemArmour->setAutoSize(true);
                GemArmour->setForeColour(Color::White);
                Point tempVar34(4, ItemLabel->getDisplayRectangle()->Bottom);
                GemArmour->setLocation(&tempVar34);
                GemArmour->setOutLine(true);
                GemArmour->setParent(ItemLabel);
                GemArmour->setText("-Armour");

                Size tempVar35(std::max(ItemLabel->getSize()->Width, GemArmour->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, GemArmour->getDisplayRectangle()->Bottom));
                ItemLabel->setSize(&tempVar35);

                delete GemArmour;
            }
            #pragma endregion
            #pragma region Helmet text
            count++;
            if (HoverItem->Info->Unique::HasFlag(SpecialItemMode::ClearRing))
            {
                MirLabel *Gemhelmet = new MirLabel();
                Gemhelmet->setAutoSize(true);
                Gemhelmet->setForeColour(Color::White);
                Point tempVar36(4, ItemLabel->getDisplayRectangle()->Bottom);
                Gemhelmet->setLocation(&tempVar36);
                Gemhelmet->setOutLine(true);
                Gemhelmet->setParent(ItemLabel);
                Gemhelmet->setText("-Helmet");

                Size tempVar37(std::max(ItemLabel->getSize()->Width, Gemhelmet->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, Gemhelmet->getDisplayRectangle()->Bottom));
                ItemLabel->setSize(&tempVar37);

                delete Gemhelmet;
            }
            #pragma endregion
            #pragma region Necklace text
            count++;
            if (HoverItem->Info->Unique::HasFlag(SpecialItemMode::Protection))
            {
                MirLabel *Gemnecklace = new MirLabel();
                Gemnecklace->setAutoSize(true);
                Gemnecklace->setForeColour(Color::White);
                Point tempVar38(4, ItemLabel->getDisplayRectangle()->Bottom);
                Gemnecklace->setLocation(&tempVar38);
                Gemnecklace->setOutLine(true);
                Gemnecklace->setParent(ItemLabel);
                Gemnecklace->setText("-Necklace");

                Size tempVar39(std::max(ItemLabel->getSize()->Width, Gemnecklace->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, Gemnecklace->getDisplayRectangle()->Bottom));
                ItemLabel->setSize(&tempVar39);

                delete Gemnecklace;
            }
            #pragma endregion
            #pragma region Bracelet text
            count++;
            if (HoverItem->Info->Unique::HasFlag(SpecialItemMode::Revival))
            {
                MirLabel *GemBracelet = new MirLabel();
                GemBracelet->setAutoSize(true);
                GemBracelet->setForeColour(Color::White);
                Point tempVar40(4, ItemLabel->getDisplayRectangle()->Bottom);
                GemBracelet->setLocation(&tempVar40);
                GemBracelet->setOutLine(true);
                GemBracelet->setParent(ItemLabel);
                GemBracelet->setText("-Bracelet");

                Size tempVar41(std::max(ItemLabel->getSize()->Width, GemBracelet->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, GemBracelet->getDisplayRectangle()->Bottom));
                ItemLabel->setSize(&tempVar41);

                delete GemBracelet;
            }
            #pragma endregion
            #pragma region Ring text
            count++;
            if (HoverItem->Info->Unique::HasFlag(SpecialItemMode::Muscle))
            {
                MirLabel *GemRing = new MirLabel();
                GemRing->setAutoSize(true);
                GemRing->setForeColour(Color::White);
                Point tempVar42(4, ItemLabel->getDisplayRectangle()->Bottom);
                GemRing->setLocation(&tempVar42);
                GemRing->setOutLine(true);
                GemRing->setParent(ItemLabel);
                GemRing->setText("-Ring");

                Size tempVar43(std::max(ItemLabel->getSize()->Width, GemRing->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, GemRing->getDisplayRectangle()->Bottom));
                ItemLabel->setSize(&tempVar43);

                delete GemRing;
            }
            #pragma endregion
            #pragma region Amulet text
            count++;
            if (HoverItem->Info->Unique::HasFlag(SpecialItemMode::Flame))
            {
                MirLabel *Gemamulet = new MirLabel();
                Gemamulet->setAutoSize(true);
                Gemamulet->setForeColour(Color::White);
                Point tempVar44(4, ItemLabel->getDisplayRectangle()->Bottom);
                Gemamulet->setLocation(&tempVar44);
                Gemamulet->setOutLine(true);
                Gemamulet->setParent(ItemLabel);
                Gemamulet->setText("-Amulet");

                Size tempVar45(std::max(ItemLabel->getSize()->Width, Gemamulet->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, Gemamulet->getDisplayRectangle()->Bottom));
                ItemLabel->setSize(&tempVar45);

                delete Gemamulet;
            }
            #pragma endregion
            #pragma region Belt text
            count++;
            if (HoverItem->Info->Unique::HasFlag(SpecialItemMode::Healing))
            {
                MirLabel *Gembelt = new MirLabel();
                Gembelt->setAutoSize(true);
                Gembelt->setForeColour(Color::White);
                Point tempVar46(4, ItemLabel->getDisplayRectangle()->Bottom);
                Gembelt->setLocation(&tempVar46);
                Gembelt->setOutLine(true);
                Gembelt->setParent(ItemLabel);
                Gembelt->setText("-Belt");

                Size tempVar47(std::max(ItemLabel->getSize()->Width, Gembelt->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, Gembelt->getDisplayRectangle()->Bottom));
                ItemLabel->setSize(&tempVar47);

                delete Gembelt;
            }
            #pragma endregion
            #pragma region Boots text
            count++;
            if (HoverItem->Info->Unique::HasFlag(SpecialItemMode::Probe))
            {
                MirLabel *Gemboots = new MirLabel();
                Gemboots->setAutoSize(true);
                Gemboots->setForeColour(Color::White);
                Point tempVar48(4, ItemLabel->getDisplayRectangle()->Bottom);
                Gemboots->setLocation(&tempVar48);
                Gemboots->setOutLine(true);
                Gemboots->setParent(ItemLabel);
                Gemboots->setText("-Boots");

                Size tempVar49(std::max(ItemLabel->getSize()->Width, Gemboots->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, Gemboots->getDisplayRectangle()->Bottom));
                ItemLabel->setSize(&tempVar49);

                delete Gemboots;
            }
            #pragma endregion
            #pragma region Stone text
            count++;
            if (HoverItem->Info->Unique::HasFlag(SpecialItemMode::Skill))
            {
                MirLabel *Gemstone = new MirLabel();
                Gemstone->setAutoSize(true);
                Gemstone->setForeColour(Color::White);
                Point tempVar50(4, ItemLabel->getDisplayRectangle()->Bottom);
                Gemstone->setLocation(&tempVar50);
                Gemstone->setOutLine(true);
                Gemstone->setParent(ItemLabel);
                Gemstone->setText("-Stone");

                Size tempVar51(std::max(ItemLabel->getSize()->Width, Gemstone->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, Gemstone->getDisplayRectangle()->Bottom));
                ItemLabel->setSize(&tempVar51);

                delete Gemstone;
            }
            #pragma endregion
            #pragma region Torch text
            count++;
            if (HoverItem->Info->Unique::HasFlag(SpecialItemMode::NoDuraLoss))
            {
                MirLabel *Gemtorch = new MirLabel();
                Gemtorch->setAutoSize(true);
                Gemtorch->setForeColour(Color::White);
                Point tempVar52(4, ItemLabel->getDisplayRectangle()->Bottom);
                Gemtorch->setLocation(&tempVar52);
                Gemtorch->setOutLine(true);
                Gemtorch->setParent(ItemLabel);
                Gemtorch->setText("-Candle");

                Size tempVar53(std::max(ItemLabel->getSize()->Width, Gemtorch->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, Gemtorch->getDisplayRectangle()->Bottom));
                ItemLabel->setSize(&tempVar53);

                delete Gemtorch;
            }
            #pragma endregion

            delete GemUseOn;
        }

        #pragma endregion

        #pragma region CANTAWAKEN

        //if ((HoverItem.Info.CanAwakening != true) && (HoverItem.Info.Type != ItemType.Gem))
        //{
        //    count++;
        //    MirLabel CANTAWAKENINGLabel = new MirLabel
        //    {
        //        AutoSize = true,
        //        ForeColour = Color.Yellow,
        //        Location = new Point(4, ItemLabel.DisplayRectangle.Bottom),
        //        OutLine = true,
        //        Parent = ItemLabel,
        //        Text = string.Format("Can't awaken")
        //    };

        //    ItemLabel.Size = new Size(Math.Max(ItemLabel.Size.Width, CANTAWAKENINGLabel.DisplayRectangle.Right + 4),
        //        Math.Max(ItemLabel.Size.Height, CANTAWAKENINGLabel.DisplayRectangle.Bottom));
        //}

        #pragma endregion

        #pragma region EXPIRE

        if (HoverItem->ExpireInfo != nullptr)
        {
            double remainingSeconds = (HoverItem->ExpireInfo->ExpiryDate - DateTime::Now).TotalSeconds;

            count++;
            MirLabel *EXPIRELabel = new MirLabel();
            EXPIRELabel->setAutoSize(true);
            EXPIRELabel->setForeColour(Color::Yellow);
            Point tempVar54(4, ItemLabel->getDisplayRectangle()->Bottom);
            EXPIRELabel->setLocation(&tempVar54);
            EXPIRELabel->setOutLine(true);
            EXPIRELabel->setParent(ItemLabel);
            EXPIRELabel->setText(remainingSeconds > 0 ? StringHelper::formatSimple("Expires in {0}", Functions::PrintTimeSpanFromSeconds(remainingSeconds)) : "Expired");

            Size tempVar55(std::max(ItemLabel->getSize()->Width, EXPIRELabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, EXPIRELabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar55);

            delete EXPIRELabel;
        }

        #pragma endregion

        if (HoverItem->RentalInformation == nullptr ? nullptr : HoverItem->RentalInformation->RentalLocked == false)
        {

            count++;
            MirLabel *OWNERLabel = new MirLabel();
            OWNERLabel->setAutoSize(true);
            OWNERLabel->setForeColour(Color::DarkKhaki);
            Point tempVar56(4, ItemLabel->getDisplayRectangle()->Bottom);
            OWNERLabel->setLocation(&tempVar56);
            OWNERLabel->setOutLine(true);
            OWNERLabel->setParent(ItemLabel);
            OWNERLabel->setText("Item rented from: " + HoverItem->RentalInformation->OwnerName);

            Size tempVar57(std::max(ItemLabel->getSize()->Width, OWNERLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, OWNERLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar57);

            double remainingTime = (HoverItem->RentalInformation->ExpiryDate - DateTime::Now).TotalSeconds;

            count++;
            MirLabel *RENTALLabel = new MirLabel();
            RENTALLabel->setAutoSize(true);
            RENTALLabel->setForeColour(Color::Khaki);
            Point tempVar58(4, ItemLabel->getDisplayRectangle()->Bottom);
            RENTALLabel->setLocation(&tempVar58);
            RENTALLabel->setOutLine(true);
            RENTALLabel->setParent(ItemLabel);
            RENTALLabel->setText(remainingTime > 0 ? StringHelper::formatSimple("Rental expires in: {0}", Functions::PrintTimeSpanFromSeconds(remainingTime)) : "Rental expired");

            Size tempVar59(std::max(ItemLabel->getSize()->Width, RENTALLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, RENTALLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar59);

            delete RENTALLabel;
            delete OWNERLabel;
        }
        else if (HoverItem->RentalInformation == nullptr ? nullptr : HoverItem->RentalInformation->RentalLocked == true && HoverItem->RentalInformation->ExpiryDate > DateTime::Now)
        {
            count++;
            auto remainingTime = (HoverItem->RentalInformation->ExpiryDate - DateTime::Now).TotalSeconds;
            auto RentalLockLabel = new MirLabel();
            RentalLockLabel->setAutoSize(true);
            RentalLockLabel->setForeColour(Color::DarkKhaki);
            Point tempVar60(4, ItemLabel->getDisplayRectangle()->Bottom);
            RentalLockLabel->setLocation(&tempVar60);
            RentalLockLabel->setOutLine(true);
            RentalLockLabel->setParent(ItemLabel);
            RentalLockLabel->setText(remainingTime > 0 ? StringHelper::formatSimple("Rental lock expires in: {0}", Functions::PrintTimeSpanFromSeconds(remainingTime)) : "Rental lock expired");

            Size tempVar61(std::max(ItemLabel->getSize()->Width, RentalLockLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, RentalLockLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar61);

            delete RentalLockLabel;
        }

        if (count > 0)
        {
            Size tempVar62(ItemLabel->getSize()->Width, ItemLabel->getSize()->Height + 4);
            ItemLabel->setSize(&tempVar62);

            #pragma region OUTLINE
            MirControl *outLine = new MirControl();
            outLine->setBackColour(Color::FromArgb(255, 50, 50, 50));
            outLine->setBorder(true);
            outLine->setBorderColour(Color::Gray);
            outLine->setNotControl(true);
            outLine->setParent(ItemLabel);
            outLine->setOpacity(0.4F);
            Point tempVar63(0, 0);
            outLine->setLocation(&tempVar63);
            outLine->setSize(ItemLabel->getSize());
            #pragma endregion

//C# TO C++ CONVERTER TODO TASK: A 'delete outLine' statement was not added since outLine was used in a 'return' or 'throw' statement.
            return outLine;
        }
        else
        {
            Size tempVar64(ItemLabel->getSize()->Width, ItemLabel->getSize()->Height - 4);
            ItemLabel->setSize(&tempVar64);
        }
        return nullptr;
    }

    MirControl *GameScene::OverlapInfoLabel(UserItem *item, bool Inspect)
    {
        unsigned short level = Inspect ? InspectDialog->Level : MapObject::User->Level;
        MirClass job = Inspect ? InspectDialog->Class : MapObject::User->Class;
        HoverItem = item;
        ItemInfo *realItem = Functions::GetRealItem(item->Info, level, job, ItemInfoList);

        Size tempVar(ItemLabel->getSize()->Width, ItemLabel->getSize()->Height + 4);
        ItemLabel->setSize(&tempVar);

        int count = 0;


        #pragma region GEM

        if (realItem->Type == ItemType::Gem)
        {
            std::string text = "";

            switch (realItem->Shape)
            {
                case 1:
                    text = "Hold CTRL and left click to repair weapons.";
                    break;
                case 2:
                    text = "Hold CTRL and left click to repair armour\nand accessory items.";
                    break;
                case 3:
                case 4:
                    text = "Hold CTRL and left click to combine with an item.";
                    break;
            }
            count++;
            MirLabel *GEMLabel = new MirLabel();
            GEMLabel->setAutoSize(true);
            GEMLabel->setForeColour(Color::White);
            Point tempVar2(4, ItemLabel->getDisplayRectangle()->Bottom);
            GEMLabel->setLocation(&tempVar2);
            GEMLabel->setOutLine(true);
            GEMLabel->setParent(ItemLabel);
            GEMLabel->setText(text);

            Size tempVar3(std::max(ItemLabel->getSize()->Width, GEMLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, GEMLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar3);

            delete GEMLabel;
        }

        #pragma endregion

        #pragma region SPLITUP

        if (realItem->StackSize > 1 && realItem->Type != ItemType::Gem)
        {
            count++;
            MirLabel *SPLITUPLabel = new MirLabel();
            SPLITUPLabel->setAutoSize(true);
            SPLITUPLabel->setForeColour(Color::White);
            Point tempVar4(4, ItemLabel->getDisplayRectangle()->Bottom);
            SPLITUPLabel->setLocation(&tempVar4);
            SPLITUPLabel->setOutLine(true);
            SPLITUPLabel->setParent(ItemLabel);
            SPLITUPLabel->setText(std::string::Format(GameLanguage::MaxCombine, realItem->StackSize, "\n"));

            Size tempVar5(std::max(ItemLabel->getSize()->Width, SPLITUPLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, SPLITUPLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar5);

            delete SPLITUPLabel;
        }

        #pragma endregion

        if (count > 0)
        {
            Size tempVar6(ItemLabel->getSize()->Width, ItemLabel->getSize()->Height + 4);
            ItemLabel->setSize(&tempVar6);

            #pragma region OUTLINE
            MirControl *outLine = new MirControl();
            outLine->setBackColour(Color::FromArgb(255, 50, 50, 50));
            outLine->setBorder(true);
            outLine->setBorderColour(Color::Gray);
            outLine->setNotControl(true);
            outLine->setParent(ItemLabel);
            outLine->setOpacity(0.4F);
            Point tempVar7(0, 0);
            outLine->setLocation(&tempVar7);
            outLine->setSize(ItemLabel->getSize());
            #pragma endregion

//C# TO C++ CONVERTER TODO TASK: A 'delete outLine' statement was not added since outLine was used in a 'return' or 'throw' statement.
            return outLine;
        }
        else
        {
            Size tempVar8(ItemLabel->getSize()->Width, ItemLabel->getSize()->Height - 4);
            ItemLabel->setSize(&tempVar8);
        }
        return nullptr;
    }

    MirControl *GameScene::StoryInfoLabel(UserItem *item, bool Inspect)
    {
        unsigned short level = Inspect ? InspectDialog->Level : MapObject::User->Level;
        MirClass job = Inspect ? InspectDialog->Class : MapObject::User->Class;
        HoverItem = item;
        ItemInfo *realItem = Functions::GetRealItem(item->Info, level, job, ItemInfoList);

        Size tempVar(ItemLabel->getSize()->Width, ItemLabel->getSize()->Height + 4);
        ItemLabel->setSize(&tempVar);

        int count = 0;

        #pragma region TOOLTIP

        if (realItem->Type == ItemType::Scroll && realItem->Shape == 7) //Credit Scroll
        {
            HoverItem->Info->ToolTip = StringHelper::formatSimple("Adds {0} Credits to your Account.", HoverItem->Info->Price);
        }

        if (!HoverItem->Info->ToolTip.empty())
        {
            count++;

            MirLabel *IDLabel = new MirLabel();
            IDLabel->setAutoSize(true);
            IDLabel->setForeColour(Color::DarkKhaki);
            Point tempVar2(4, ItemLabel->getDisplayRectangle()->Bottom);
            IDLabel->setLocation(&tempVar2);
            IDLabel->setOutLine(true);
            IDLabel->setParent(ItemLabel);
            IDLabel->setText(GameLanguage::ItemDescription);

            Size tempVar3(std::max(ItemLabel->getSize()->Width, IDLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, IDLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar3);

            MirLabel *TOOLTIPLabel = new MirLabel();
            TOOLTIPLabel->setAutoSize(true);
            TOOLTIPLabel->setForeColour(Color::Khaki);
            Point tempVar4(4, ItemLabel->getDisplayRectangle()->Bottom);
            TOOLTIPLabel->setLocation(&tempVar4);
            TOOLTIPLabel->setOutLine(true);
            TOOLTIPLabel->setParent(ItemLabel);
            TOOLTIPLabel->setText(HoverItem->Info->ToolTip);

            Size tempVar5(std::max(ItemLabel->getSize()->Width, TOOLTIPLabel->getDisplayRectangle()->Right + 4), std::max(ItemLabel->getSize()->Height, TOOLTIPLabel->getDisplayRectangle()->Bottom));
            ItemLabel->setSize(&tempVar5);

            delete TOOLTIPLabel;
            delete IDLabel;
        }

        #pragma endregion

        if (count > 0)
        {
            Size tempVar6(ItemLabel->getSize()->Width, ItemLabel->getSize()->Height + 4);
            ItemLabel->setSize(&tempVar6);

            #pragma region OUTLINE
            MirControl *outLine = new MirControl();
            outLine->setBackColour(Color::FromArgb(255, 50, 50, 50));
            outLine->setBorder(true);
            outLine->setBorderColour(Color::Gray);
            outLine->setNotControl(true);
            outLine->setParent(ItemLabel);
            outLine->setOpacity(0.4F);
            Point tempVar7(0, 0);
            outLine->setLocation(&tempVar7);
            outLine->setSize(ItemLabel->getSize());
            #pragma endregion

//C# TO C++ CONVERTER TODO TASK: A 'delete outLine' statement was not added since outLine was used in a 'return' or 'throw' statement.
            return outLine;
        }
        else
        {
            Size tempVar8(ItemLabel->getSize()->Width, ItemLabel->getSize()->Height - 4);
            ItemLabel->setSize(&tempVar8);
        }
        return nullptr;
    }

    void GameScene::CreateItemLabel(UserItem *item, bool inspect, bool hideDura, bool hideAdded)
    {
        if (item == nullptr)
        {
            DisposeItemLabel();
            HoverItem = nullptr;
            return;
        }

        if (item == HoverItem && ItemLabel != nullptr && !ItemLabel->isDisposed())
        {
            return;
        }
        unsigned short level = inspect ? InspectDialog->Level : MapObject::User->Level;
        MirClass job = inspect ? InspectDialog->Class : MapObject::User->Class;
        HoverItem = item;
        ItemInfo *realItem = Functions::GetRealItem(item->Info, level, job, ItemInfoList);

        ItemLabel = new MirControl();
        ItemLabel->setBackColour(Color::FromArgb(255, 50, 50, 50));
        ItemLabel->setBorder(true);
        ItemLabel->setBorderColour(Color::Gray);
        ItemLabel->setDrawControlTexture(true);
        ItemLabel->setNotControl(true);
        ItemLabel->setParent(this);
        ItemLabel->setOpacity(0.7F);

        //Name Info Label
        std::vector<MirControl*> outlines(10);
        outlines[0] = NameInfoLabel(item, inspect, hideDura);
        //Attribute Info1 Label - Attack Info
        outlines[1] = AttackInfoLabel(item, inspect, hideAdded);
        //Attribute Info2 Label - Defence Info
        outlines[2] = DefenceInfoLabel(item, inspect, hideAdded);
        //Attribute Info3 Label - Weight Info
        outlines[3] = WeightInfoLabel(item, inspect);
        //Awake Info Label
        outlines[4] = AwakeInfoLabel(item, inspect);
        //Socket Info Label
        outlines[5] = SocketInfoLabel(item, inspect);
        //need Info Label
        outlines[6] = NeedInfoLabel(item, inspect);
        //Bind Info Label
        outlines[7] = BindInfoLabel(item, inspect, hideAdded);
        //Overlap Info Label
        outlines[8] = OverlapInfoLabel(item, inspect);
        //Story Label
        outlines[9] = StoryInfoLabel(item, inspect);

        for (auto outline : outlines)
        {
            if (outline != nullptr)
            {
                Size tempVar(ItemLabel->getSize()->Width, outline->getSize()->Height);
                outline->setSize(&tempVar);
            }
        }

        //ItemLabel.Visible = true;
    }

    void GameScene::CreateMailLabel(ClientMail *mail)
    {
        if (mail == nullptr)
        {
            DisposeMailLabel();
            return;
        }

        if (MailLabel != nullptr && !MailLabel->isDisposed())
        {
            return;
        }

        MailLabel = new MirControl();
        MailLabel->setBackColour(Color::FromArgb(255, 50, 50, 50));
        MailLabel->setBorder(true);
        MailLabel->setBorderColour(Color::Gray);
        MailLabel->setDrawControlTexture(true);
        MailLabel->setNotControl(true);
        MailLabel->setParent(this);
        MailLabel->setOpacity(0.7F);

        MirLabel *nameLabel = new MirLabel();
        nameLabel->setAutoSize(true);
        nameLabel->setForeColour(Color::Yellow);
        Point tempVar(4, 4);
        nameLabel->setLocation(&tempVar);
        nameLabel->setOutLine(true);
        nameLabel->setParent(MailLabel);
        nameLabel->setText(mail->SenderName);

        Size tempVar2(std::max(MailLabel->getSize()->Width, nameLabel->getDisplayRectangle()->Right + 4), std::max(MailLabel->getSize()->Height, nameLabel->getDisplayRectangle()->Bottom));
        MailLabel->setSize(&tempVar2);

        MirLabel *dateLabel = new MirLabel();
        dateLabel->setAutoSize(true);
        dateLabel->setForeColour(Color::White);
        Point tempVar3(4, MailLabel->getDisplayRectangle()->Bottom);
        dateLabel->setLocation(&tempVar3);
        dateLabel->setOutLine(true);
        dateLabel->setParent(MailLabel);
//C# TO C++ CONVERTER TODO TASK: There is no C++ equivalent to 'ToString':
        dateLabel->setText(std::string::Format(GameLanguage::DateSent, mail->DateSent.ToString("dd/MM/yy H:mm:ss")));

        Size tempVar4(std::max(MailLabel->getSize()->Width, dateLabel->getDisplayRectangle()->Right + 4), std::max(MailLabel->getSize()->Height, dateLabel->getDisplayRectangle()->Bottom));
        MailLabel->setSize(&tempVar4);

        if (mail->Gold > 0)
        {
            MirLabel *goldLabel = new MirLabel();
            goldLabel->setAutoSize(true);
            goldLabel->setForeColour(Color::White);
            Point tempVar5(4, MailLabel->getDisplayRectangle()->Bottom);
            goldLabel->setLocation(&tempVar5);
            goldLabel->setOutLine(true);
            goldLabel->setParent(MailLabel);
            goldLabel->setText("Gold: " + std::to_string(mail->Gold));

            Size tempVar6(std::max(MailLabel->getSize()->Width, goldLabel->getDisplayRectangle()->Right + 4), std::max(MailLabel->getSize()->Height, goldLabel->getDisplayRectangle()->Bottom));
            MailLabel->setSize(&tempVar6);

            delete goldLabel;
        }

        MirLabel *openedLabel = new MirLabel();
        openedLabel->setAutoSize(true);
        openedLabel->setForeColour(Color::Red);
        Point tempVar7(4, MailLabel->getDisplayRectangle()->Bottom);
        openedLabel->setLocation(&tempVar7);
        openedLabel->setOutLine(true);
        openedLabel->setParent(MailLabel);
        openedLabel->setText(mail->Opened ? "[Old]" : "[New]");

        Size tempVar8(std::max(MailLabel->getSize()->Width, openedLabel->getDisplayRectangle()->Right + 4), std::max(MailLabel->getSize()->Height, openedLabel->getDisplayRectangle()->Bottom));
        MailLabel->setSize(&tempVar8);

        delete openedLabel;
        delete dateLabel;
        delete nameLabel;
    }

    void GameScene::CreateMemoLabel(ClientFriend *friend_Keyword)
    {
        if (friend_Keyword == nullptr)
        {
            DisposeMemoLabel();
            return;
        }

        if (MemoLabel != nullptr && !MemoLabel->isDisposed())
        {
            return;
        }

        MemoLabel = new MirControl();
        MemoLabel->setBackColour(Color::FromArgb(255, 50, 50, 50));
        MemoLabel->setBorder(true);
        MemoLabel->setBorderColour(Color::Gray);
        MemoLabel->setDrawControlTexture(true);
        MemoLabel->setNotControl(true);
        MemoLabel->setParent(this);
        MemoLabel->setOpacity(0.7F);

        MirLabel *memoLabel = new MirLabel();
        memoLabel->setAutoSize(true);
        memoLabel->setForeColour(Color::White);
        Point tempVar(4, 4);
        memoLabel->setLocation(&tempVar);
        memoLabel->setOutLine(true);
        memoLabel->setParent(MemoLabel);
        memoLabel->setText(Functions::StringOverLines(friend_Keyword->Memo, 5, 20));

        Size tempVar2(std::max(MemoLabel->getSize()->Width, memoLabel->getDisplayRectangle()->Right + 4), std::max(MemoLabel->getSize()->Height, memoLabel->getDisplayRectangle()->Bottom + 4));
        MemoLabel->setSize(&tempVar2);

        delete memoLabel;
    }

    ItemInfo *GameScene::GetInfo(int index)
    {
        for (int i = 0; i < ItemInfoList.size(); i++)
        {
            ItemInfo *info = ItemInfoList[i];
            if (info->Index != index)
            {
                continue;
            }
            return info;
        }

        return nullptr;
    }

    std::string GameScene::GetUserName(unsigned int id)
    {
        for (int i = 0; i < UserIdList.size(); i++)
        {
            UserId *who = UserIdList[i];
            if (id == who->Id)
            {
                return who->UserName;
            }
        }
        C::RequestUserName *tempVar = new C::RequestUserName();
        tempVar->UserID = id;
        Network::Enqueue(tempVar);
        UserId *tempVar2 = new UserId();
        tempVar2->Id = id;
        tempVar2->UserName = "Unknown";
        UserIdList.push_back(tempVar2);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar2' statement was not added since tempVar2 was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
        return "";
    }

    void GameScene::Rankings(S::Rankings *p)
    {
        RankingDialog->RecieveRanks(p->Listings, p->RankType, p->MyRank);
    }

    void GameScene::Opendoor(S::Opendoor *p)
    {
        MapControl->OpenDoor(p->DoorIndex, p->Close);
    }

    void GameScene::RentedItems(S::GetRentedItems *p)
    {
        ItemRentalDialog->ReceiveRentedItems(p->RentedItems);
    }

    void GameScene::ItemRentalRequest(S::ItemRentalRequest *p)
    {
        if (!p->Renting)
        {
            GuestItemRentDialog->SetGuestName(p->Name);
            ItemRentingDialog->OpenItemRentalDialog();
        }
        else
        {
            GuestItemRentingDialog->SetGuestName(p->Name);
            ItemRentDialog->OpenItemRentDialog();
        }

        ItemRentalDialog->setVisible(false);
    }

    void GameScene::ItemRentalFee(S::ItemRentalFee *p)
    {
        GuestItemRentDialog->SetGuestFee(p->Amount);
        ItemRentDialog->RefreshInterface();
    }

    void GameScene::ItemRentalPeriod(S::ItemRentalPeriod *p)
    {
        GuestItemRentingDialog->GuestRentalPeriod = p->Days;
        ItemRentingDialog->RefreshInterface();
    }

    void GameScene::DepositRentalItem(S::DepositRentalItem *p)
    {
        auto fromCell = p->From < getUser()->BeltIdx ? BeltDialog->Grid[p->From] : InventoryDialog->Grid[p->From - getUser()->BeltIdx];
        auto toCell = ItemRentingDialog->ItemCell;

        if (toCell == nullptr || fromCell == nullptr)
        {
            return;
        }

        toCell->setLocked(false);
        fromCell->setLocked(false);

        if (!p->Success)
        {
            return;
        }

        toCell->setItem(fromCell->getItem());
        fromCell->setItem(nullptr);
        getUser()->RefreshStats();

        if (ItemRentingDialog->RentalPeriod == 0)
        {
            ItemRentingDialog->InputRentalPeroid();
        }
    }

    void GameScene::RetrieveRentalItem(S::RetrieveRentalItem *p)
    {
        auto fromCell = ItemRentingDialog->ItemCell;
        auto toCell = p->To < getUser()->BeltIdx ? BeltDialog->Grid[p->To] : InventoryDialog->Grid[p->To - getUser()->BeltIdx];

        if (toCell == nullptr || fromCell == nullptr)
        {
            return;
        }

        toCell->setLocked(false);
        fromCell->setLocked(false);

        if (!p->Success)
        {
            return;
        }

        toCell->setItem(fromCell->getItem());
        fromCell->setItem(nullptr);
        getUser()->RefreshStats();
    }

    void GameScene::UpdateRentalItem(S::UpdateRentalItem *p)
    {
        GuestItemRentingDialog::GuestLoanItem = p->LoanItem;
        ItemRentDialog->RefreshInterface();
    }

    void GameScene::CancelItemRental(S::CancelItemRental *p)
    {
        getUser()->RentalGoldLocked = false;
        getUser()->RentalItemLocked = false;

        ItemRentingDialog->Reset();
        ItemRentDialog->Reset();

        auto messageBox = new MirMessageBox("Item rental cancelled.\r\n" + "To complete item rental please face the other party throughout the transaction.");
        messageBox->Show();

        delete messageBox;
    }

    void GameScene::ItemRentalLock(S::ItemRentalLock *p)
    {
        if (!p->Success)
        {
            return;
        }

        getUser()->RentalGoldLocked = p->GoldLocked;
        getUser()->RentalItemLocked = p->ItemLocked;

        if (getUser()->RentalGoldLocked)
        {
            ItemRentDialog->Lock();
        }
        else if (getUser()->RentalItemLocked)
        {
            ItemRentingDialog->Lock();
        }
    }

    void GameScene::ItemRentalPartnerLock(S::ItemRentalPartnerLock *p)
    {
        if (p->GoldLocked)
        {
            GuestItemRentDialog->Lock();
        }
        else if (p->ItemLocked)
        {
            GuestItemRentingDialog->Lock();
        }
    }

    void GameScene::CanConfirmItemRental(S::CanConfirmItemRental *p)
    {
        ItemRentingDialog->EnableConfirmButton();
    }

    void GameScene::ConfirmItemRental(S::ConfirmItemRental *p)
    {
        getUser()->RentalGoldLocked = false;
        getUser()->RentalItemLocked = false;

        ItemRentingDialog->Reset();
        ItemRentDialog->Reset();
    }

    void GameScene::OpenBrowser(S::OpenBrowser *p)
    {
        BrowserHelper::OpenDefaultBrowser(p->Url);
    }

    void GameScene::PlaySound(S::PlaySound *p)
    {
        SoundManager::PlaySound(p->Sound, false);
    }

    void GameScene::SetTimer(S::SetTimer *p)
    {
        GameScene::Scene->TimerControl->AddTimer(p);
    }

    void GameScene::ExpireTimer(S::ExpireTimer *p)
    {
        GameScene::Scene->TimerControl->ExpireTimer(p->Key);
    }

    void GameScene::ShowNotice(S::UpdateNotice *p)
    {
        NoticeDialog->Update(p->Notice);
    }

    void GameScene::Dispose(bool disposing)
    {
        if (disposing)
        {
            Scene = nullptr;
            setUser(nullptr);

            MoveTime = 0;
            AttackTime = 0;
            NextRunTime = 0;
            LastRunTime = 0;
            CanMove = false;
            CanRun = false;

            MapControl = nullptr;
            MainDialog = nullptr;
            ChatDialog = nullptr;
            ChatControl = nullptr;
            InventoryDialog = nullptr;
            CharacterDialog = nullptr;
            StorageDialog = nullptr;
            BeltDialog = nullptr;
            MiniMapDialog = nullptr;
            InspectDialog = nullptr;
            OptionDialog = nullptr;
            MenuDialog = nullptr;
            NPCDialog = nullptr;
            QuestDetailDialog = nullptr;
            QuestListDialog = nullptr;
            QuestLogDialog = nullptr;
            QuestTrackingDialog = nullptr;
            GameShopDialog = nullptr;
            MentorDialog = nullptr;

            RelationshipDialog = nullptr;
            CharacterDuraPanel = nullptr;
            DuraStatusPanel = nullptr;

            HoverItem = nullptr;
            SelectedCell = nullptr;
            PickedUpGold = false;

            UseItemTime = 0;
            PickUpTime = 0;
            InspectTime = 0;

            DisposeItemLabel();

            AMode = (AttackMode)0;
            PMode = (PetMode)0;
            Lights = (LightSetting)0;

            NPCTime = 0;
            NPCID = 0;
            DefaultNPCID = 0;

            for (int i = 0; i < OutputLines.size(); i++)
            {
                if (OutputLines[i] != nullptr && OutputLines[i]->isDisposed())
                {
                    OutputLines[i]->Dispose();
                }
            }

            OutputMessages.clear();
            OutputMessages = std::vector<OutPutMessage*>();
        }

        MirScene::Dispose(disposing);
    }

    UserObject *MapControl::getUser()
    {
        return MapObject::User;
    }

    void MapControl::setUser(UserObject *value)
    {
        MapObject::User = value;
    }

std::vector<MapObject*> MapControl::Objects;
int MapControl::OffSetX = 0;
int MapControl::OffSetY = 0;
int MapControl::ViewRangeX = 0;
int MapControl::ViewRangeY = 0;

    Point *MapControl::getMapLocation()
    {
        Point tempVar(MouseLocation->X / CellWidth - OffSetX, MouseLocation->Y / CellHeight - OffSetY);
        return GameScene::getUser() == nullptr ? Point::Empty : (&tempVar)->Add(GameScene::getUser()->CurrentLocation);
    }

MouseButtons *MapControl::MapButtons;
Point *MapControl::MouseLocation;
long long MapControl::InputDelay = 0;
long long MapControl::NextAction = 0;
bool MapControl::_awakeningAction = false;

    bool MapControl::getAwakeningAction()
    {
        return _awakeningAction;
    }

    void MapControl::setAwakeningAction(bool value)
    {
        if (_awakeningAction == value)
        {
            return;
        }
        _awakeningAction = value;
    }

bool MapControl::_autoRun = false;

    bool MapControl::getAutoRun()
    {
        return _autoRun;
    }

    void MapControl::setAutoRun(bool value)
    {
        if (_autoRun == value)
        {
            return;
        }
        _autoRun = value;
        if (GameScene::Scene != nullptr)
        {
            GameScene::Scene->ChatDialog->ReceiveChat(value ? "[AutoRun: On]" : "[AutoRun: Off]", ChatType::Hint);
        }
    }

bool MapControl::AutoHit = false;
std::vector<Client::MirObjects::Effect*> MapControl::Effects;

    MapControl::MapControl()
    {
        MapButtons = MouseButtons::None;

        OffSetX = Settings::ScreenWidth / 2 / CellWidth;
        OffSetY = Settings::ScreenHeight / 2 / CellHeight - 1;

        ViewRangeX = OffSetX + 4;
        ViewRangeY = OffSetY + 4;

        Size tempVar(Settings::ScreenWidth, Settings::ScreenHeight);
        setSize(&tempVar);
        setDrawControlTexture(true);
        setBackColour(Color::Black);

        MouseDown += OnMouseDown;
        MouseMove += [&] (o, e)
        {
            MouseLocation = e::Location;
        };
        Click += OnMouseClick;
    }

    void MapControl::LoadMap()
    {
        GameScene::Scene->NPCDialog->Hide();
        Objects.clear();
        Effects.clear();
        Doors.clear();

        if (getUser() != nullptr)
        {
            Objects.push_back(getUser());
        }



        MapObject::MouseObject = nullptr;
        MapObject::TargetObject = nullptr;
        MapObject::MagicObject = nullptr;
        MapReader *Map = new MapReader(FileName);
        M2CellInfo = Map->MapCells;
        Width = Map->Width;
        Height = Map->Height;

        try
        {
            if (SetMusic != Music)
            {
                if (SoundManager::Music != nullptr)
                {
                    SoundManager::Music->Dispose();
                }

                SoundManager::PlayMusic(Music, true);
            }
        }
        catch (const std::runtime_error &e1)
        {
            // Do nothing. index was not valid.
        }

        SetMusic = Music;
        SoundList::Music = Music;

        delete Map;
    }

    void MapControl::Process()
    {
        Processdoors();
        getUser()->Process();
        for (int i = Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = Objects[i];
            if (ob == getUser())
            {
                continue;
            }
            //  if (ob.ActionFeed.Count > 0 || ob.Effects.Count > 0 || GameScene.CanMove || CMain.Time >= ob.NextMotion)
            ob->Process();
        }

        for (int i = Effects.size() - 1; i >= 0; i--)
        {
            Effects[i]->Process();
        }

        if (MapObject::TargetObject != nullptr && dynamic_cast<MonsterObject*>(MapObject::TargetObject) != nullptr && MapObject::TargetObject->AI == 64)
        {
            MapObject::TargetObject = nullptr;
        }
        if (MapObject::MagicObject != nullptr && dynamic_cast<MonsterObject*>(MapObject::MagicObject) != nullptr && MapObject::MagicObject->AI == 64)
        {
            MapObject::MagicObject = nullptr;
        }

        CheckInput();


        MapObject *bestmouseobject = nullptr;
        for (int y = getMapLocation()->Y + 2; y >= getMapLocation()->Y - 2; y--)
        {
            if (y >= Height)
            {
                continue;
            }
            if (y < 0)
            {
                break;
            }
            for (int x = getMapLocation()->X + 2; x >= getMapLocation()->X - 2; x--)
            {
                if (x >= Width)
                {
                    continue;
                }
                if (x < 0)
                {
                    break;
                }
                CellInfo *cell = M2CellInfo[x][y];
                if (cell->CellObjects.empty())
                {
                    continue;
                }

                for (int i = cell->CellObjects.size() - 1; i >= 0; i--)
                {
                    MapObject *ob = cell->CellObjects[i];
                    if (ob == MapObject::User || !ob->MouseOver(CMain::MPoint))
                    {
                        continue;
                    }

                    if (MapObject::MouseObject != ob)
                    {
                        if (ob->Dead)
                        {
                            if (!Settings::TargetDead && GameScene::TargetDeadTime <= CMain::Time)
                            {
                                continue;
                            }

                            bestmouseobject = ob;
                            //continue;
                        }
                        MapObject::MouseObject = ob;
                        Redraw();
                    }
                    if (bestmouseobject != nullptr && MapObject::MouseObject == nullptr)
                    {
                        MapObject::MouseObject = bestmouseobject;
                        Redraw();
                    }
                    return;
                }
            }
        }


        if (MapObject::MouseObject != nullptr)
        {
            MapObject::MouseObject = nullptr;
            Redraw();
        }
    }

    MapObject *MapControl::GetObject(unsigned int targetID)
    {
        for (int i = 0; i < Objects.size(); i++)
        {
            MapObject *ob = Objects[i];
            if (ob->ObjectID != targetID)
            {
                continue;
            }
            return ob;
        }
        return nullptr;
    }

    void MapControl::Draw()
    {
        //Do nothing.
    }

    void MapControl::CreateTexture()
    {
        if (getUser() == nullptr)
        {
            return;
        }

        if (!FloorValid)
        {
            DrawFloor();
        }


        if (ControlTexture != nullptr && !ControlTexture->Disposed && getSize() != TextureSize)
        {
            ControlTexture->Dispose();
        }

        if (ControlTexture == nullptr || ControlTexture->Disposed)
        {
            DXManager::ControlList.push_back(this);
            ControlTexture = new Texture(DXManager::Device, getSize()->Width, getSize()->Height, 1, Usage::RenderTarget, Format::A8R8G8B8, Pool::Default);
            TextureSize = getSize();
        }

        Surface *oldSurface = DXManager::CurrentSurface;
        Surface *surface = ControlTexture->GetSurfaceLevel(0);
        DXManager::SetSurface(surface);
        DXManager::Device->Clear(ClearFlags::Target, getBackColour(), 0, 0);

        DrawBackground();

        if (FloorValid)
        {
            Rectangle tempVar(0, 0, Settings::ScreenWidth, Settings::ScreenHeight);
            DXManager::Sprite->Draw(DXManager::FloorTexture, &tempVar, Vector3::Zero, Vector3::Zero, Color::White);
        }

        DrawObjects();

        //Render Death, 

        LightSetting setting = Lights == LightSetting::Normal ? GameScene::Scene->Lights : Lights;

        if (setting != LightSetting::Day || GameScene::getUser()->Poison::HasFlag(PoisonType::Blindness))
        {
            DrawLights(setting);
        }

        if (Settings::DropView || GameScene::DropViewTime > CMain::Time)
        {
            for (int i = 0; i < Objects.size(); i++)
            {
                ItemObject *ob = dynamic_cast<ItemObject*>(Objects[i]);
                if (ob == nullptr)
                {
                    continue;
                }

                if (!ob->MouseOver(MouseLocation))
                {
                    ob->DrawName();
                }
            }
        }

        if (MapObject::MouseObject != nullptr && !(dynamic_cast<ItemObject*>(MapObject::MouseObject) != nullptr))
        {
            MapObject::MouseObject->DrawName();
        }

        int offSet = 0;
        for (int i = 0; i < Objects.size(); i++)
        {
            ItemObject *ob = dynamic_cast<ItemObject*>(Objects[i]);
            if (ob == nullptr)
            {
                continue;
            }

            if (!ob->MouseOver(MouseLocation))
            {
                continue;
            }
            ob->DrawName(offSet);
            offSet -= ob->NameLabel->getSize()->Height + (ob->NameLabel->getBorder() ? 1 : 0);
        }

        if (MapObject::User->MouseOver(MouseLocation))
        {
            MapObject::User->DrawName();
        }

        DXManager::SetSurface(oldSurface);
        surface->Dispose();
        TextureValid = true;

    }

    void MapControl::DrawControl()
    {
        if (!getDrawControlTexture())
        {
            return;
        }

        if (!TextureValid)
        {
            CreateTexture();
        }

        if (ControlTexture == nullptr || ControlTexture->Disposed)
        {
            return;
        }

        float oldOpacity = DXManager::Opacity;

        if (MapObject::User->Dead)
        {
            DXManager::SetGrayscale(true);
        }

        DXManager::SetOpacity(getOpacity());
        Rectangle tempVar(0, 0, Settings::ScreenWidth, Settings::ScreenHeight);
        DXManager::Sprite->Draw(ControlTexture, &tempVar, Vector3::Zero, Vector3::Zero, Color::White);
        DXManager::SetOpacity(oldOpacity);

        if (MapObject::User->Dead)
        {
            DXManager::SetGrayscale(false);
        }

        CleanTime = CMain::Time + Settings::CleanDelay;
    }

    void MapControl::DrawFloor()
    {
        if (DXManager::FloorTexture == nullptr || DXManager::FloorTexture->Disposed)
        {
            DXManager::FloorTexture = new Texture(DXManager::Device, Settings::ScreenWidth, Settings::ScreenHeight, 1, Usage::RenderTarget, Format::A8R8G8B8, Pool::Default);
            DXManager::FloorSurface = DXManager::FloorTexture->GetSurfaceLevel(0);
        }


        Surface *oldSurface = DXManager::CurrentSurface;

        DXManager::SetSurface(DXManager::FloorSurface);
        DXManager::Device->Clear(ClearFlags::Target, Color::Empty, 0, 0); //Color.Black

        int index;
        int drawY, drawX;

        for (int y = getUser()->Movement->Y - ViewRangeY; y <= getUser()->Movement->Y + ViewRangeY; y++)
        {
            if (y <= 0 || y % 2 == 1)
            {
                continue;
            }
            if (y >= Height)
            {
                break;
            }
            drawY = (y - getUser()->Movement->Y + OffSetY) * CellHeight + getUser()->OffSetMove->Y; //Moving OffSet

            for (int x = getUser()->Movement->X - ViewRangeX; x <= getUser()->Movement->X + ViewRangeX; x++)
            {
                if (x <= 0 || x % 2 == 1)
                {
                    continue;
                }
                if (x >= Width)
                {
                    break;
                }
                drawX = (x - getUser()->Movement->X + OffSetX) * CellWidth - OffSetX + getUser()->OffSetMove->X; //Moving OffSet
                if ((M2CellInfo[x][y].BackImage == 0) || (M2CellInfo[x][y].BackIndex == -1))
                {
                    continue;
                }
                index = (M2CellInfo[x][y].BackImage & 0x1FFFFFFF) - 1;
                Libraries::MapLibs[M2CellInfo[x, y].BackIndex]->Draw(index, drawX, drawY);
            }
        }

        for (int y = getUser()->Movement->Y - ViewRangeY; y <= getUser()->Movement->Y + ViewRangeY + 5; y++)
        {
            if (y <= 0)
            {
                continue;
            }
            if (y >= Height)
            {
                break;
            }
            drawY = (y - getUser()->Movement->Y + OffSetY) * CellHeight + getUser()->OffSetMove->Y; //Moving OffSet

            for (int x = getUser()->Movement->X - ViewRangeX; x <= getUser()->Movement->X + ViewRangeX; x++)
            {
                if (x < 0)
                {
                    continue;
                }
                if (x >= Width)
                {
                    break;
                }
                drawX = (x - getUser()->Movement->X + OffSetX) * CellWidth - OffSetX + getUser()->OffSetMove->X; //Moving OffSet

                index = M2CellInfo[x][y].MiddleImage - 1;

                if ((index < 0) || (M2CellInfo[x][y].MiddleIndex == -1))
                {
                    continue;
                }
                if (M2CellInfo[x][y].MiddleIndex > 199)
                { //mir3 mid layer is same level as front layer not real middle + it cant draw index -1 so 2 birds in one stone :p
                    Size *s = Libraries::MapLibs[M2CellInfo[x, y].MiddleIndex]->GetSize(index);

                    if (s->Width != CellWidth || s->Height != CellHeight)
                    {
                        continue;
                    }
                }
                Libraries::MapLibs[M2CellInfo[x, y].MiddleIndex]->Draw(index, drawX, drawY);
            }
        }
        for (int y = getUser()->Movement->Y - ViewRangeY; y <= getUser()->Movement->Y + ViewRangeY + 5; y++)
        {
            if (y <= 0)
            {
                continue;
            }
            if (y >= Height)
            {
                break;
            }
            drawY = (y - getUser()->Movement->Y + OffSetY) * CellHeight + getUser()->OffSetMove->Y; //Moving OffSet

            for (int x = getUser()->Movement->X - ViewRangeX; x <= getUser()->Movement->X + ViewRangeX; x++)
            {
                if (x < 0)
                {
                    continue;
                }
                if (x >= Width)
                {
                    break;
                }
                drawX = (x - getUser()->Movement->X + OffSetX) * CellWidth - OffSetX + getUser()->OffSetMove->X; //Moving OffSet

                index = (M2CellInfo[x][y].FrontImage & 0x7FFF) - 1;
                if (index == -1)
                {
                    continue;
                }
                int fileIndex = M2CellInfo[x][y].FrontIndex;
                if (fileIndex == -1)
                {
                    continue;
                }
                Size *s = Libraries::MapLibs[fileIndex]->GetSize(index);
                if (fileIndex == 200)
                {
                    continue; //fixes random bad spots on old school 4.map
                }
                if (M2CellInfo[x][y].DoorIndex > 0)
                {
                    Door *DoorInfo = GetDoor(M2CellInfo[x][y].DoorIndex);
                    if (DoorInfo == nullptr)
                    {
                        DoorInfo = new Door();
                        DoorInfo->index = M2CellInfo[x][y].DoorIndex;
                        DoorInfo->DoorState = (DoorState)0;
                        DoorInfo->ImageIndex = 0;
                        DoorInfo->LastTick = CMain::Time;
                        Doors.push_back(DoorInfo);
                    }
                    else
                    {
                        if (DoorInfo->DoorState != (DoorState)0)
                        {
                            index += (DoorInfo->ImageIndex + 1) * M2CellInfo[x][y].DoorOffset; //'bad' code if you want to use animation but it's gonna depend on the animation > has to be custom designed for the animtion
                        }
                    }
                }

                if (index < 0 || ((s->Width != CellWidth || s->Height != CellHeight) && ((s->Width != CellWidth * 2) || (s->Height != CellHeight * 2))))
                {
                    continue;
                }
                Libraries::MapLibs[fileIndex]->Draw(index, drawX, drawY);
            }
        }

        DXManager::SetSurface(oldSurface);

        FloorValid = true;
    }

    void MapControl::DrawBackground()
    {
        std::string cleanFilename = StringHelper::replace(FileName, Settings::MapPath, "");

        if (StringHelper::startsWith(cleanFilename, "ID1") || StringHelper::startsWith(cleanFilename, "ID2"))
        {
            Libraries::Background->Draw(10, 0, 0); //mountains
        }
        else if (StringHelper::startsWith(cleanFilename, "ID3_013"))
        {
            Libraries::Background->Draw(22, 0, 0); //desert
        }
        else if (StringHelper::startsWith(cleanFilename, "ID3_015"))
        {
            Libraries::Background->Draw(23, 0, 0); //greatwall
        }
        else if (StringHelper::startsWith(cleanFilename, "ID3_023") || StringHelper::startsWith(cleanFilename, "ID3_025"))
        {
            Libraries::Background->Draw(21, 0, 0); //village entrance
        }
    }

    void MapControl::DrawObjects()
    {
        for (int y = getUser()->Movement->Y - ViewRangeY; y <= getUser()->Movement->Y + ViewRangeY + 25; y++)
        {
            if (y <= 0)
            {
                continue;
            }
            if (y >= Height)
            {
                break;
            }
            for (int x = getUser()->Movement->X - ViewRangeX; x <= getUser()->Movement->X + ViewRangeX; x++)
            {
                if (x < 0)
                {
                    continue;
                }
                if (x >= Width)
                {
                    break;
                }
                M2CellInfo[x][y].DrawDeadObjects();
            }
        }

        for (int y = getUser()->Movement->Y - ViewRangeY; y <= getUser()->Movement->Y + ViewRangeY + 25; y++)
        {
            if (y <= 0)
            {
                continue;
            }
            if (y >= Height)
            {
                break;
            }
            int drawY = (y - getUser()->Movement->Y + OffSetY + 1) * CellHeight + getUser()->OffSetMove->Y;

            for (int x = getUser()->Movement->X - ViewRangeX; x <= getUser()->Movement->X + ViewRangeX; x++)
            {
                if (x < 0)
                {
                    continue;
                }
                if (x >= Width)
                {
                    break;
                }
                int drawX = (x - getUser()->Movement->X + OffSetX) * CellWidth - OffSetX + getUser()->OffSetMove->X;
                int index;
                unsigned char animation;
                bool blend;
                Size *s;
                #pragma region Draw shanda's tile animation layer
                index = M2CellInfo[x][y].TileAnimationImage;
                animation = M2CellInfo[x][y].TileAnimationFrames;
                if ((index > 0) & (animation > 0))
                {
                    index--;
                    int animationoffset = M2CellInfo[x][y].TileAnimationOffset ^ 0x2000;
                    index += animationoffset * (AnimationCount % animation);
                    Libraries::MapLibs[190]->DrawUp(index, drawX, drawY);
                }

                #pragma endregion

                #pragma region Draw mir3 middle layer
                if ((M2CellInfo[x][y].MiddleIndex > 199) && (M2CellInfo[x][y].MiddleIndex != -1))
                {
                    index = M2CellInfo[x][y].MiddleImage - 1;
                    if (index > 0)
                    {
                        animation = M2CellInfo[x][y].MiddleAnimationFrame;
                        blend = false;
                        if ((animation > 0) && (animation < 255))
                        {
                            if ((animation & 0x0f) > 0)
                            {
                                blend = true;
                                animation &= 0x0f;
                            }
                            if (animation > 0)
                            {
                                unsigned char animationTick = M2CellInfo[x][y].MiddleAnimationTick;
                                index += (AnimationCount % (animation + (animation * animationTick))) / (1 + animationTick);

                                if (blend && (animation == 10 || animation == 8)) //diamond mines, abyss blends
                                {
                                    Point tempVar(drawX, drawY);
                                    Libraries::MapLibs[M2CellInfo[x, y].MiddleIndex]->DrawUpBlend(index, &tempVar);
                                }
                                else
                                {
                                    Libraries::MapLibs[M2CellInfo[x, y].MiddleIndex]->DrawUp(index, drawX, drawY);
                                }
                            }
                        }
                        s = Libraries::MapLibs[M2CellInfo[x, y].MiddleIndex]->GetSize(index);
                        if ((s->Width != CellWidth || s->Height != CellHeight) && (s->Width != (CellWidth * 2) || s->Height != (CellHeight * 2)) && !blend)
                        {
                            Libraries::MapLibs[M2CellInfo[x, y].MiddleIndex]->DrawUp(index, drawX, drawY);
                        }
                    }
                }
                #pragma endregion

                #pragma region Draw front layer
                index = (M2CellInfo[x][y].FrontImage & 0x7FFF) - 1;

                if (index < 0)
                {
                    continue;
                }

                int fileIndex = M2CellInfo[x][y].FrontIndex;
                if (fileIndex == -1)
                {
                    continue;
                }
                animation = M2CellInfo[x][y].FrontAnimationFrame;

                if ((animation & 0x80) > 0)
                {
                    blend = true;
                    animation &= 0x7F;
                }
                else
                {
                    blend = false;
                }


                if (animation > 0)
                {
                    unsigned char animationTick = M2CellInfo[x][y].FrontAnimationTick;
                    index += (AnimationCount % (animation + (animation * animationTick))) / (1 + animationTick);
                }


                if (M2CellInfo[x][y].DoorIndex > 0)
                {
                    Door *DoorInfo = GetDoor(M2CellInfo[x][y].DoorIndex);
                    if (DoorInfo == nullptr)
                    {
                        DoorInfo = new Door();
                        DoorInfo->index = M2CellInfo[x][y].DoorIndex;
                        DoorInfo->DoorState = (DoorState)0;
                        DoorInfo->ImageIndex = 0;
                        DoorInfo->LastTick = CMain::Time;
                        Doors.push_back(DoorInfo);
                    }
                    else
                    {
                        if (DoorInfo->DoorState != (DoorState)0)
                        {
                            index += (DoorInfo->ImageIndex + 1) * M2CellInfo[x][y].DoorOffset; //'bad' code if you want to use animation but it's gonna depend on the animation > has to be custom designed for the animtion
                        }
                    }
                }

                s = Libraries::MapLibs[fileIndex]->GetSize(index);
                if (s->Width == CellWidth && s->Height == CellHeight && animation == 0)
                {
                    continue;
                }
                if ((s->Width == CellWidth * 2) && (s->Height == CellHeight * 2) && (animation == 0))
                {
                    continue;
                }

                if (blend)
                {
                    if ((fileIndex > 99) & (fileIndex < 199))
                    {
                        Point tempVar2(drawX, drawY - (3 * CellHeight));
                        Libraries::MapLibs[fileIndex]->DrawBlend(index, &tempVar2, Color::White, true);
                    }
                    else
                    {
                        Point tempVar3(drawX, drawY - s->Height);
                        Libraries::MapLibs[fileIndex]->DrawBlend(index, &tempVar3, Color::White, (index >= 2723 && index <= 2732));
                    }
                }
                else
                {
                    Libraries::MapLibs[fileIndex]->Draw(index, drawX, drawY - s->Height);
                }
                #pragma endregion
            }

            for (int x = getUser()->Movement->X - ViewRangeX; x <= getUser()->Movement->X + ViewRangeX; x++)
            {
                if (x < 0)
                {
                    continue;
                }
                if (x >= Width)
                {
                    break;
                }
                M2CellInfo[x][y].DrawObjects();
            }
        }

        DXManager::Sprite->Flush();
        float oldOpacity = DXManager::Opacity;
        DXManager::SetOpacity(0.4F);

        //MapObject.User.DrawMount();

        MapObject::User->DrawBody();

        if ((MapObject::User->Direction == MirDirection::Up) || (MapObject::User->Direction == MirDirection::UpLeft) || (MapObject::User->Direction == MirDirection::UpRight) || (MapObject::User->Direction == MirDirection::Right) || (MapObject::User->Direction == MirDirection::Left))
        {
            MapObject::User->DrawHead();
            MapObject::User->DrawWings();
        }
        else
        {
            MapObject::User->DrawWings();
            MapObject::User->DrawHead();
        }

        DXManager::SetOpacity(oldOpacity);

        if (Settings::HighlightTarget)
        {
            if (MapObject::MouseObject != nullptr && !MapObject::MouseObject->Dead && MapObject::MouseObject != MapObject::TargetObject && MapObject::MouseObject->Blend)
            {
                MapObject::MouseObject->DrawBlend();
            }

            if (MapObject::TargetObject != nullptr)
            {
                MapObject::TargetObject->DrawBlend();
            }
        }

        for (int i = 0; i < Objects.size(); i++)
        {
            Objects[i]->DrawEffects(Settings::Effect);

            if (Settings::NameView && !(dynamic_cast<ItemObject*>(Objects[i]) != nullptr) && !Objects[i]->Dead)
            {
                Objects[i]->DrawName();
            }

            Objects[i]->DrawChat();
            Objects[i]->DrawHealth();
            Objects[i]->DrawPoison();

            Objects[i]->DrawDamages();
        }


        if (!Settings::Effect)
        {
            return;
        }

        for (int i = Effects.size() - 1; i >= 0; i--)
        {
            Effects[i]->Draw();
        }
    }

    Color *MapControl::GetBlindLight(Color *light)
    {
        if (MapObject::User->BlindTime <= CMain::Time && MapObject::User->BlindCount < 25)
        {
            MapObject::User->BlindTime = CMain::Time + 100;
            MapObject::User->BlindCount++;
        }

        int count = MapObject::User->BlindCount;
        light = Color::FromArgb(255, std::max(20, light->R - (count * 10)), std::max(20, light->G - (count * 10)), std::max(20, light->B - (count * 10)));

        return light;
    }

    void MapControl::DrawLights(LightSetting setting)
    {
        if (DXManager::Lights.empty() || DXManager::Lights.empty())
        {
            return;
        }

        if (DXManager::LightTexture == nullptr || DXManager::LightTexture->Disposed)
        {
            DXManager::LightTexture = new Texture(DXManager::Device, Settings::ScreenWidth, Settings::ScreenHeight, 1, Usage::RenderTarget, Format::A8R8G8B8, Pool::Default);
            DXManager::LightSurface = DXManager::LightTexture->GetSurfaceLevel(0);
        }

        Surface *oldSurface = DXManager::CurrentSurface;
        DXManager::SetSurface(DXManager::LightSurface);

        #pragma region Night Lights
        Color *darkness;

        switch (setting)
        {
            case LightSetting::Night:
            {
                    switch (MapDarkLight)
                    {
                        case 1:
                            darkness = Color::FromArgb(255, 20, 20, 20);
                            break;
                        case 2:
                            darkness = Color::LightSlateGray;
                            break;
                        case 3:
                            darkness = Color::SkyBlue;
                            break;
                        case 4:
                            darkness = Color::Goldenrod;
                            break;
                        default:
                            darkness = Color::Black;
                            break;
                    }
            }
                break;
            case LightSetting::Evening:
            case LightSetting::Dawn:
                darkness = Color::FromArgb(255, 50, 50, 50);
                break;
            default:
            case LightSetting::Day:
                darkness = Color::FromArgb(255, 255, 255, 255);
                break;
        }

        if (MapObject::User->Poison::HasFlag(PoisonType::Blindness))
        {
            darkness = GetBlindLight(darkness);
        }

        CMain::DebugText = std::string::Format("{0},{1},{2},{3}", darkness->A, darkness->R, darkness->G, darkness->B);

        DXManager::Device->Clear(ClearFlags::Target, darkness, 0, 0);

        #pragma endregion

        int light;
        Point *p;
        DXManager::SetBlend(true);
        DXManager::Device->SetRenderState(SlimDX::Direct3D9::RenderState::SourceBlend, Blend::SourceAlpha);

        #pragma region Object Lights (Player/Mob/NPC)
        for (int i = 0; i < Objects.size(); i++)
        {
            MapObject *ob = Objects[i];
            if (ob->Light > 0 && (!ob->Dead || ob == MapObject::User || ob->getRace() == ObjectType::Spell))
            {
                light = ob->Light;

                int lightRange = light % 15;
                if (lightRange >= DXManager::Lights.size())
                {
                    lightRange = DXManager::Lights.size() - 1;
                }

                p = ob->DrawLocation;

                Color *lightColour = ob->LightColour;

                if (ob->getRace() == ObjectType::Player)
                {
                    switch (light / 15)
                    {
                        case 0: //no light source
                            lightColour = Color::FromArgb(255, 60, 60, 60);
                            break;
                        case 1:
                            lightColour = Color::FromArgb(255, 120, 120, 120);
                            break;
                        case 2: //Candle
                            lightColour = Color::FromArgb(255, 180, 180, 180);
                            break;
                        case 3: //Torch
                            lightColour = Color::FromArgb(255, 240, 240, 240);
                            break;
                        default: //Peddler Torch
                            lightColour = Color::FromArgb(255, 255, 255, 255);
                            break;
                    }
                }
                else if (ob->getRace() == ObjectType::Merchant)
                {
                    lightColour = Color::FromArgb(255, 120, 120, 120);
                }

                if (MapObject::User->Poison::HasFlag(PoisonType::Blindness))
                {
                    lightColour = GetBlindLight(lightColour);
                }

                if (DXManager::Lights[lightRange] != nullptr && !DXManager::Lights[lightRange]->Disposed)
                {
                    p->Offset(-(DXManager::LightSizes[lightRange]->X / 2) - (CellWidth / 2), -(DXManager::LightSizes[lightRange]->Y / 2) - (CellHeight / 2) - 5);
                    Vector3 tempVar(static_cast<float>(p->X), static_cast<float>(p->Y), 0.0F);
                    DXManager::Sprite->Draw(DXManager::Lights[lightRange], nullptr, Vector3::Zero, &tempVar, lightColour);
                }
            }

            #pragma region Object Effect Lights
            if (!Settings::Effect)
            {
                continue;
            }
            for (int e = 0; e < ob->Effects.size(); e++)
            {
                Effect *effect = ob->Effects[e];
                if (!effect->Blend || CMain::Time < effect->Start || (!(dynamic_cast<Missile*>(effect) != nullptr) && effect->Light < ob->Light))
                {
                    continue;
                }

                light = effect->Light;

                p = effect->DrawLocation;

                auto lightColour = effect->LightColour;

                if (MapObject::User->Poison::HasFlag(PoisonType::Blindness))
                {
                    lightColour = GetBlindLight(lightColour);
                }

                if (DXManager::Lights[light] != nullptr && !DXManager::Lights[light]->Disposed)
                {
                    p->Offset(-(DXManager::LightSizes[light]->X / 2) - (CellWidth / 2), -(DXManager::LightSizes[light]->Y / 2) - (CellHeight / 2) - 5);
                    Vector3 tempVar2(static_cast<float>(p->X), static_cast<float>(p->Y), 0.0F);
                    DXManager::Sprite->Draw(DXManager::Lights[light], nullptr, Vector3::Zero, &tempVar2, lightColour);
                }

            }
            #pragma endregion
        }
        #pragma endregion

        #pragma region Map Effect Lights
        if (Settings::Effect)
        {
            for (int e = 0; e < Effects.size(); e++)
            {
                Effect *effect = Effects[e];
                if (!effect->Blend || CMain::Time < effect->Start)
                {
                    continue;
                }

                light = effect->Light;
                if (light == 0)
                {
                    continue;
                }

                p = effect->DrawLocation;

                auto lightColour = Color::White;

                if (MapObject::User->Poison::HasFlag(PoisonType::Blindness))
                {
                    lightColour = GetBlindLight(lightColour);
                }

                if (DXManager::Lights[light] != nullptr && !DXManager::Lights[light]->Disposed)
                {
                    p->Offset(-(DXManager::LightSizes[light]->X / 2) - (CellWidth / 2), -(DXManager::LightSizes[light]->Y / 2) - (CellHeight / 2) - 5);
                    Vector3 tempVar3(static_cast<float>(p->X), static_cast<float>(p->Y), 0.0F);
                    DXManager::Sprite->Draw(DXManager::Lights[light], nullptr, Vector3::Zero, &tempVar3, lightColour);
                }
            }
        }
        #pragma endregion

        #pragma region Map Lights
        for (int y = MapObject::User->Movement->Y - ViewRangeY - 24; y <= MapObject::User->Movement->Y + ViewRangeY + 24; y++)
        {
            if (y < 0)
            {
                continue;
            }
            if (y >= Height)
            {
                break;
            }
            for (int x = MapObject::User->Movement->X - ViewRangeX - 24; x < MapObject::User->Movement->X + ViewRangeX + 24; x++)
            {
                if (x < 0)
                {
                    continue;
                }
                if (x >= Width)
                {
                    break;
                }
                int imageIndex = (M2CellInfo[x][y].FrontImage & 0x7FFF) - 1;
                if (M2CellInfo[x][y].Light <= 0 || M2CellInfo[x][y].Light >= 10)
                {
                    continue;
                }
                if (M2CellInfo[x][y].Light == 0)
                {
                    continue;
                }

                Color *lightIntensity;

                light = (M2CellInfo[x][y].Light % 10) * 3;

                switch (M2CellInfo[x][y].Light / 10)
                {
                    case 1:
                        lightIntensity = Color::FromArgb(255, 255, 255, 255);
                        break;
                    case 2:
                        lightIntensity = Color::FromArgb(255, 120, 180, 255);
                        break;
                    case 3:
                        lightIntensity = Color::FromArgb(255, 255, 180, 120);
                        break;
                    case 4:
                        lightIntensity = Color::FromArgb(255, 22, 160, 5);
                        break;
                    default:
                        lightIntensity = Color::FromArgb(255, 255, 255, 255);
                        break;
                }

                if (MapObject::User->Poison::HasFlag(PoisonType::Blindness))
                {
                    lightIntensity = GetBlindLight(lightIntensity);
                }

                int fileIndex = M2CellInfo[x][y].FrontIndex;

                p = new Point((x + OffSetX - MapObject::User->Movement->X) * CellWidth + MapObject::User->OffSetMove->X, (y + OffSetY - MapObject::User->Movement->Y) * CellHeight + MapObject::User->OffSetMove->Y + 32);


                if (M2CellInfo[x][y].FrontAnimationFrame > 0)
                {
                    p->Offset(Libraries::MapLibs[fileIndex]->GetOffSet(imageIndex));
                }

                if (light >= DXManager::Lights.size())
                {
                    light = DXManager::Lights.size() - 1;
                }

                if (DXManager::Lights[light] != nullptr && !DXManager::Lights[light]->Disposed)
                {
                    p->Offset(-(DXManager::LightSizes[light]->X / 2) - (CellWidth / 2) + 10, -(DXManager::LightSizes[light]->Y / 2) - (CellHeight / 2) - 5);
                    Vector3 tempVar4(static_cast<float>(p->X), static_cast<float>(p->Y), 0.0F);
                    DXManager::Sprite->Draw(DXManager::Lights[light], nullptr, Vector3::Zero, &tempVar4, lightIntensity);
                }
            }
        }
        #pragma endregion

        DXManager::SetBlend(false);
        DXManager::SetSurface(oldSurface);

        DXManager::Device->SetRenderState(SlimDX::Direct3D9::RenderState::SourceBlend, Blend::DestinationColor);
        DXManager::Device->SetRenderState(SlimDX::Direct3D9::RenderState::DestinationBlend, Blend::BothInverseSourceAlpha);

        Rectangle tempVar5(0, 0, Settings::ScreenWidth, Settings::ScreenHeight);
        DXManager::Sprite->Draw(DXManager::LightTexture, &tempVar5, Vector3::Zero, Vector3::Zero, Color::White);
        DXManager::Sprite->End();
        DXManager::Sprite->Begin(SpriteFlags::AlphaBlend);

        delete p;
    }

    void MapControl::OnMouseClick(std::any sender, EventArgs *e)
    {
        MouseEventArgs *me = dynamic_cast<MouseEventArgs*>(e);
        if (!(me != nullptr))
        {
            return;
        }

        if (getAwakeningAction() == true)
        {
            return;
        }
        switch (me->Button)
        {
            case MouseButtons->Left:
            {
                    setAutoRun(false);
                    if (MapObject::MouseObject == nullptr)
                    {
                        return;
                    }
                    NPCObject *npc = dynamic_cast<NPCObject*>(MapObject::MouseObject);
                    if (npc != nullptr)
                    {
                        if (npc->ObjectID == GameScene::NPCID && (CMain::Time <= GameScene::NPCTime || GameScene::Scene->NPCDialog->getVisible()))
                        {
                            return;
                        }

                        //GameScene.Scene.NPCDialog.Hide();

                        GameScene::NPCTime = CMain::Time + 5000;
                        GameScene::NPCID = npc->ObjectID;
                        C::CallNPC *tempVar = new C::CallNPC();
                        tempVar->ObjectID = npc->ObjectID;
                        tempVar->Key = "[@Main]";
                        Network::Enqueue(tempVar);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
                    }
            }
                break;
            case MouseButtons::Right:
            {
                    setAutoRun(false);
                    if (MapObject::MouseObject == nullptr)
                    {
                        return;
                    }
                    PlayerObject *player = dynamic_cast<PlayerObject*>(MapObject::MouseObject);
                    if (player == nullptr || player == getUser() || !CMain::Ctrl)
                    {
                        return;
                    }
                    if (CMain::Time <= GameScene::InspectTime && player->ObjectID == InspectDialog::InspectID)
                    {
                        return;
                    }

                    GameScene::InspectTime = CMain::Time + 500;
                    InspectDialog::InspectID = player->ObjectID;
                    C::Inspect *tempVar2 = new C::Inspect();
                    tempVar2->ObjectID = player->ObjectID;
                    Network::Enqueue(tempVar2);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar2' statement was not added since tempVar2 was passed to a method or constructor. Handle memory management manually.
            }
                break;
            case MouseButtons::Middle:
                setAutoRun(!getAutoRun());
                break;
        }
    }

    void MapControl::OnMouseDown(std::any sender, MouseEventArgs *e)
    {
        MapButtons |= e->Button;
        GameScene::CanRun = false;

        if (getAwakeningAction() == true)
        {
            return;
        }

        if (e->Button != MouseButtons->Left)
        {
            return;
        }

        if (GameScene::SelectedCell != nullptr)
        {
            if (GameScene::SelectedCell->getGridType() != MirGridType::Inventory)
            {
                GameScene::SelectedCell = nullptr;
                return;
            }

            MirItemCell *cell = GameScene::SelectedCell;
            if (cell->getItem()->Info->Bind::HasFlag(BindMode::DontDrop))
            {
                MirMessageBox *messageBox = new MirMessageBox(StringHelper::formatSimple("You cannot drop {0}", cell->getItem()->getFriendlyName()), MirMessageBoxButtons::OK);
                messageBox->Show();
                GameScene::SelectedCell = nullptr;

                delete messageBox;
                return;
            }
            if (cell->getItem()->Count == 1)
            {
                MirMessageBox *messageBox = new MirMessageBox(std::string::Format(GameLanguage::DropTip, cell->getItem()->getFriendlyName()), MirMessageBoxButtons::YesNo);

                messageBox->YesButton->Click += [&] (o, a)
                {
                    C::DropItem *tempVar = new C::DropItem();
                    tempVar->UniqueID = cell->getItem()->UniqueID;
                    tempVar->Count = 1;
                    Network::Enqueue(tempVar);
    
                    cell->setLocked(true);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
                };
                messageBox->Show();

                delete messageBox;
            }
            else
            {
                MirAmountBox *amountBox = new MirAmountBox(GameLanguage::DropAmount, cell->getItem()->Info->Image, cell->getItem()->Count);

                amountBox->OKButton->Click += [&] (o, a)
                {
                    if (amountBox->Amount <= 0)
                    {
                        return;
                    }
                    C::DropItem *tempVar2 = new C::DropItem();
                    tempVar2->UniqueID = cell->getItem()->UniqueID;
                    tempVar2->Count = static_cast<unsigned short>(amountBox->Amount);
                    Network::Enqueue(tempVar2);
    
                    cell->setLocked(true);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar2' statement was not added since tempVar2 was passed to a method or constructor. Handle memory management manually.
                };

                amountBox->Show();

                delete amountBox;
            }
            GameScene::SelectedCell = nullptr;

            return;
        }

        if (GameScene::PickedUpGold)
        {
            MirAmountBox *amountBox = new MirAmountBox(GameLanguage::DropAmount, 116, GameScene::Gold);

            amountBox->OKButton->Click += [&] (o, a)
            {
                if (amountBox->Amount > 0)
                {
                    C::DropGold *tempVar3 = new C::DropGold();
                    tempVar3->Amount = amountBox->Amount;
                    Network::Enqueue(tempVar3);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
                }
            };

            amountBox->Show();
            GameScene::PickedUpGold = false;

            delete amountBox;
        }

        if (MapObject::MouseObject != nullptr && !MapObject::MouseObject->Dead && !(dynamic_cast<ItemObject*>(MapObject::MouseObject) != nullptr) && !(dynamic_cast<NPCObject*>(MapObject::MouseObject) != nullptr) && !(dynamic_cast<MonsterObject*>(MapObject::MouseObject) != nullptr && MapObject::MouseObject->AI == 64) && !(MapObject::MouseObject is MonsterObject && MapObject::MouseObject->AI == 70))
        {
            MapObject::TargetObject = MapObject::MouseObject;
            if (dynamic_cast<MonsterObject*>(MapObject::MouseObject) != nullptr && MapObject::MouseObject->AI != 6)
            {
                MapObject::MagicObject = MapObject::TargetObject;
            }
        }
        else
        {
            MapObject::TargetObject = nullptr;
        }
    }

    void MapControl::CheckInput()
    {
        if (getAwakeningAction() == true)
        {
            return;
        }

        if ((MouseControl == this) && (MapButtons != MouseButtons::None))
        {
            AutoHit = false; //mouse actions stop mining even when frozen!
        }
        if (!CanRideAttack())
        {
            AutoHit = false;
        }

        if (CMain::Time < InputDelay || getUser()->Poison::HasFlag(PoisonType::Paralysis) || getUser()->Poison::HasFlag(PoisonType::LRParalysis) || getUser()->Poison::HasFlag(PoisonType::Frozen) || getUser()->Fishing)
        {
            return;
        }

        if (getUser()->NextMagic != nullptr && !getUser()->RidingMount)
        {
            UseMagic(getUser()->NextMagic);
            return;
        }

        if (CMain::Time < getUser()->BlizzardStopTime || CMain::Time < getUser()->ReincarnationStopTime)
        {
            return;
        }

        if (MapObject::TargetObject != nullptr && !MapObject::TargetObject->Dead)
        {
            if (((StringHelper::endsWith(MapObject::TargetObject->Name, ")") || dynamic_cast<PlayerObject*>(MapObject::TargetObject) != nullptr) && CMain::Shift) || (!StringHelper::endsWith(MapObject::TargetObject->Name, ")") && dynamic_cast<MonsterObject*>(MapObject::TargetObject) != nullptr))
            {
                GameScene::LogTime = CMain::Time + Globals::LogDelay;

                if (getUser()->Class == MirClass::Archer && getUser()->getHasClassWeapon() && !getUser()->RidingMount && !getUser()->Fishing) //ArcherTest - non aggressive targets (player / pets)
                {
                    if (Functions::InRange(MapObject::TargetObject->CurrentLocation, getUser()->CurrentLocation, Globals::MaxAttackRange))
                    {
                        if (CMain::Time > GameScene::AttackTime)
                        {
                            getUser()->QueuedAction = new QueuedAction();
                            getUser()->QueuedAction->Action = MirAction::AttackRange1;
                            getUser()->QueuedAction->Direction = Functions::DirectionFromPoint(getUser()->CurrentLocation, MapObject::TargetObject->CurrentLocation);
                            getUser()->QueuedAction->Location = getUser()->CurrentLocation;
                            getUser()->QueuedAction->Params = std::vector<std::any>();
                            getUser()->QueuedAction->Params.push_back(MapObject::TargetObject != nullptr ? MapObject::TargetObject->ObjectID : static_cast<unsigned int>(0));
                            getUser()->QueuedAction->Params.push_back(MapObject::TargetObject->CurrentLocation);

                            // MapObject.TargetObject = null; //stop constant attack when close up
                        }
                    }
                    else
                    {
                        if (CMain::Time >= OutputDelay)
                        {
                            OutputDelay = CMain::Time + 1000;
                            GameScene::Scene->OutputMessage("Target is too far.");
                        }
                    }
                    //  return;
                }

                else if (Functions::InRange(MapObject::TargetObject->CurrentLocation, getUser()->CurrentLocation, 1))
                {
                    if (CMain::Time > GameScene::AttackTime && CanRideAttack() && !getUser()->Poison::HasFlag(PoisonType::Dazed))
                    {
                        getUser()->QueuedAction = new QueuedAction();
                        getUser()->QueuedAction->Action = MirAction::Attack1;
                        getUser()->QueuedAction->Direction = Functions::DirectionFromPoint(getUser()->CurrentLocation, MapObject::TargetObject->CurrentLocation);
                        getUser()->QueuedAction->Location = getUser()->CurrentLocation;
                        return;
                    }
                }
            }
        }
        if (AutoHit && !getUser()->RidingMount)
        {
            if (CMain::Time > GameScene::AttackTime)
            {
                getUser()->QueuedAction = new QueuedAction();
                getUser()->QueuedAction->Action = MirAction::Mine;
                getUser()->QueuedAction->Direction = getUser()->Direction;
                getUser()->QueuedAction->Location = getUser()->CurrentLocation;
                return;
            }
        }


        MirDirection direction;
        if (MouseControl == this)
        {
            direction = MouseDirection();
            if (getAutoRun())
            {
                if (GameScene::CanRun && CanRun(direction) && CMain::Time > GameScene::NextRunTime && getUser()->HP >= 10 && (!getUser()->Sneaking || (getUser()->Sneaking && getUser()->Sprint))) //slow remove
                {
                    int distance = getUser()->RidingMount || getUser()->Sprint && !getUser()->Sneaking ? 3 : 2;
                    bool fail = false;
                    for (int i = 1; i <= distance; i++)
                    {
                        if (!CheckDoorOpen(Functions::PointMove(getUser()->CurrentLocation, direction, i)))
                        {
                            fail = true;
                        }
                    }
                    if (!fail)
                    {
                        getUser()->QueuedAction = new QueuedAction();
                        getUser()->QueuedAction->Action = MirAction::Running;
                        getUser()->QueuedAction->Direction = direction;
                        getUser()->QueuedAction->Location = Functions::PointMove(getUser()->CurrentLocation, direction, distance);
                        return;
                    }
                }
                if ((CanWalk(direction)) && (CheckDoorOpen(Functions::PointMove(getUser()->CurrentLocation, direction, 1))))
                {
                    getUser()->QueuedAction = new QueuedAction();
                    getUser()->QueuedAction->Action = MirAction::Walking;
                    getUser()->QueuedAction->Direction = direction;
                    getUser()->QueuedAction->Location = Functions::PointMove(getUser()->CurrentLocation, direction, 1);
                    return;
                }
                if (direction != getUser()->Direction)
                {
                    getUser()->QueuedAction = new QueuedAction();
                    getUser()->QueuedAction->Action = MirAction::Standing;
                    getUser()->QueuedAction->Direction = direction;
                    getUser()->QueuedAction->Location = getUser()->CurrentLocation;
                    return;
                }
                return;
            }

            switch (MapButtons)
            {
                case MouseButtons->Left:
                    if (dynamic_cast<NPCObject*>(MapObject::MouseObject) != nullptr || (dynamic_cast<PlayerObject*>(MapObject::MouseObject) != nullptr && MapObject::MouseObject != getUser()))
                    {
                        break;
                    }
                    if (dynamic_cast<MonsterObject*>(MapObject::MouseObject) != nullptr && MapObject::MouseObject->AI == 70)
                    {
                        break;
                    }

                    if (CMain::Alt && !getUser()->RidingMount)
                    {
                        getUser()->QueuedAction = new QueuedAction();
                        getUser()->QueuedAction->Action = MirAction::Harvest;
                        getUser()->QueuedAction->Direction = direction;
                        getUser()->QueuedAction->Location = getUser()->CurrentLocation;
                        return;
                    }

                    if (CMain::Shift)
                    {
                        if (CMain::Time > GameScene::AttackTime && CanRideAttack()) //ArcherTest - shift click
                        {
                            MapObject *target = nullptr;
                            if (dynamic_cast<MonsterObject*>(MapObject::MouseObject) != nullptr || dynamic_cast<PlayerObject*>(MapObject::MouseObject) != nullptr)
                            {
                                target = MapObject::MouseObject;
                            }

                            if (getUser()->Class == MirClass::Archer && getUser()->getHasClassWeapon() && !getUser()->RidingMount && !getUser()->Poison::HasFlag(PoisonType::Dazed))
                            {
                                if (target != nullptr)
                                {
                                    if (!Functions::InRange(MapObject::MouseObject->CurrentLocation, getUser()->CurrentLocation, Globals::MaxAttackRange))
                                    {
                                        if (CMain::Time >= OutputDelay)
                                        {
                                            OutputDelay = CMain::Time + 1000;
                                            GameScene::Scene->OutputMessage("Target is too far.");
                                        }
                                        return;
                                    }
                                }

                                getUser()->QueuedAction = new QueuedAction();
                                getUser()->QueuedAction->Action = MirAction::AttackRange1;
                                getUser()->QueuedAction->Direction = MouseDirection();
                                getUser()->QueuedAction->Location = getUser()->CurrentLocation;
                                getUser()->QueuedAction->Params = std::vector<std::any>();
                                getUser()->QueuedAction->Params.push_back(target != nullptr ? target->ObjectID : static_cast<unsigned int>(0));
                                getUser()->QueuedAction->Params.push_back(Functions::PointMove(getUser()->CurrentLocation, MouseDirection(), 9));
                                return;
                            }

                            //stops double slash from being used without empty hand or assassin weapon (otherwise bugs on second swing)
                            if (GameScene::DoubleSlash && (!getUser()->getHasClassWeapon() && getUser()->Weapon > -1))
                            {
                                return;
                            }
                            if (getUser()->Poison::HasFlag(PoisonType::Dazed))
                            {
                                return;
                            }

                            getUser()->QueuedAction = new QueuedAction();
                            getUser()->QueuedAction->Action = MirAction::Attack1;
                            getUser()->QueuedAction->Direction = direction;
                            getUser()->QueuedAction->Location = getUser()->CurrentLocation;
                        }
                        return;
                    }

                    if (dynamic_cast<MonsterObject*>(MapObject::MouseObject) != nullptr && getUser()->Class == MirClass::Archer && MapObject::TargetObject != nullptr && !MapObject::TargetObject->Dead && getUser()->getHasClassWeapon() && !getUser()->RidingMount) //ArcherTest - range attack
                    {
                        if (Functions::InRange(MapObject::MouseObject->CurrentLocation, getUser()->CurrentLocation, Globals::MaxAttackRange))
                        {
                            if (CMain::Time > GameScene::AttackTime)
                            {
                                getUser()->QueuedAction = new QueuedAction();
                                getUser()->QueuedAction->Action = MirAction::AttackRange1;
                                getUser()->QueuedAction->Direction = direction;
                                getUser()->QueuedAction->Location = getUser()->CurrentLocation;
                                getUser()->QueuedAction->Params = std::vector<std::any>();
                                getUser()->QueuedAction->Params.push_back(MapObject::TargetObject->ObjectID);
                                getUser()->QueuedAction->Params.push_back(MapObject::TargetObject->CurrentLocation);
                            }
                        }
                        else
                        {
                            if (CMain::Time >= OutputDelay)
                            {
                                OutputDelay = CMain::Time + 1000;
                                GameScene::Scene->OutputMessage("Target is too far.");
                            }
                        }
                        return;
                    }

                    if (getMapLocation() == getUser()->CurrentLocation)
                    {
                        if (CMain::Time > GameScene::PickUpTime)
                        {
                            GameScene::PickUpTime = CMain::Time + 200;
                            C::PickUp tempVar();
                            Network::Enqueue(&tempVar);
                        }
                        return;
                    }

                    //mine
                    if (!ValidPoint(Functions::PointMove(getUser()->CurrentLocation, direction, 1)))
                    {
                        if ((MapObject::User->Equipment[static_cast<int>(EquipmentSlot::Weapon)] != nullptr) && (MapObject::User->Equipment[static_cast<int>(EquipmentSlot::Weapon)]->Info.CanMine))
                        {
                            if (direction != getUser()->Direction)
                            {
                                getUser()->QueuedAction = new QueuedAction();
                                getUser()->QueuedAction->Action = MirAction::Standing;
                                getUser()->QueuedAction->Direction = direction;
                                getUser()->QueuedAction->Location = getUser()->CurrentLocation;
                                return;
                            }
                            AutoHit = true;
                            return;
                        }
                    }
                    if ((CanWalk(direction)) && (CheckDoorOpen(Functions::PointMove(getUser()->CurrentLocation, direction, 1))))
                    {

                        getUser()->QueuedAction = new QueuedAction();
                        getUser()->QueuedAction->Action = MirAction::Walking;
                        getUser()->QueuedAction->Direction = direction;
                        getUser()->QueuedAction->Location = Functions::PointMove(getUser()->CurrentLocation, direction, 1);
                        return;
                    }
                    if (direction != getUser()->Direction)
                    {
                        getUser()->QueuedAction = new QueuedAction();
                        getUser()->QueuedAction->Action = MirAction::Standing;
                        getUser()->QueuedAction->Direction = direction;
                        getUser()->QueuedAction->Location = getUser()->CurrentLocation;
                        return;
                    }

                    if (CanFish(direction))
                    {
                        getUser()->FishingTime = CMain::Time;
                        C::FishingCast *tempVar2 = new C::FishingCast();
                        tempVar2->CastOut = true;
                        Network::Enqueue(tempVar2);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar2' statement was not added since tempVar2 was passed to a method or constructor. Handle memory management manually.
                        return;
                    }

                    break;
                case MouseButtons::Right:
                    if (dynamic_cast<PlayerObject*>(MapObject::MouseObject) != nullptr && MapObject::MouseObject != getUser() && CMain::Ctrl)
                    {
                        break;
                    }

                    if (Functions::InRange(getMapLocation(), getUser()->CurrentLocation, 2))
                    {
                        if (direction != getUser()->Direction)
                        {
                            getUser()->QueuedAction = new QueuedAction();
                            getUser()->QueuedAction->Action = MirAction::Standing;
                            getUser()->QueuedAction->Direction = direction;
                            getUser()->QueuedAction->Location = getUser()->CurrentLocation;
                        }
                        return;
                    }

                    GameScene::CanRun = getUser()->FastRun ? true : GameScene::CanRun;

                    if (GameScene::CanRun && CanRun(direction) && CMain::Time > GameScene::NextRunTime && getUser()->HP >= 10 && (!getUser()->Sneaking || (getUser()->Sneaking && getUser()->Sprint))) //slow removed
                    {
                        int distance = getUser()->RidingMount || getUser()->Sprint && !getUser()->Sneaking ? 3 : 2;
                        bool fail = false;
                        for (int i = 0; i <= distance; i++)
                        {
                            if (!CheckDoorOpen(Functions::PointMove(getUser()->CurrentLocation, direction, i)))
                            {
                                fail = true;
                            }
                        }
                        if (!fail)
                        {
                            getUser()->QueuedAction = new QueuedAction();
                            getUser()->QueuedAction->Action = MirAction::Running;
                            getUser()->QueuedAction->Direction = direction;
                            getUser()->QueuedAction->Location = Functions::PointMove(getUser()->CurrentLocation, direction, getUser()->RidingMount || (getUser()->Sprint && !getUser()->Sneaking) ? 3 : 2);
                            return;
                        }
                    }
                    if ((CanWalk(direction)) && (CheckDoorOpen(Functions::PointMove(getUser()->CurrentLocation, direction, 1))))
                    {
                        getUser()->QueuedAction = new QueuedAction();
                        getUser()->QueuedAction->Action = MirAction::Walking;
                        getUser()->QueuedAction->Direction = direction;
                        getUser()->QueuedAction->Location = Functions::PointMove(getUser()->CurrentLocation, direction, 1);
                        return;
                    }
                    if (direction != getUser()->Direction)
                    {
                        getUser()->QueuedAction = new QueuedAction();
                        getUser()->QueuedAction->Action = MirAction::Standing;
                        getUser()->QueuedAction->Direction = direction;
                        getUser()->QueuedAction->Location = getUser()->CurrentLocation;
                        return;
                    }
                    break;
            }
        }

        if (MapObject::TargetObject == nullptr || MapObject::TargetObject->Dead)
        {
            return;
        }
        if (((!StringHelper::endsWith(MapObject::TargetObject->Name, ")") && !(dynamic_cast<PlayerObject*>(MapObject::TargetObject) != nullptr)) || !CMain::Shift) && (StringHelper::endsWith(MapObject::TargetObject->Name, ")") || !(dynamic_cast<MonsterObject*>(MapObject::TargetObject) != nullptr)))
        {
            return;
        }
        if (Functions::InRange(MapObject::TargetObject->CurrentLocation, getUser()->CurrentLocation, 1))
        {
            return;
        }
        if (getUser()->Class == MirClass::Archer && getUser()->getHasClassWeapon() && (dynamic_cast<MonsterObject*>(MapObject::TargetObject) != nullptr || dynamic_cast<PlayerObject*>(MapObject::TargetObject) != nullptr))
        {
            return; //ArcherTest - stop walking
        }
        direction = Functions::DirectionFromPoint(getUser()->CurrentLocation, MapObject::TargetObject->CurrentLocation);

        if (!CanWalk(direction))
        {
            return;
        }

        getUser()->QueuedAction = new QueuedAction();
        getUser()->QueuedAction->Action = MirAction::Walking;
        getUser()->QueuedAction->Direction = direction;
        getUser()->QueuedAction->Location = Functions::PointMove(getUser()->CurrentLocation, direction, 1);
    }

    void MapControl::UseMagic(ClientMagic *magic)
    {
        if (CMain::Time < GameScene::SpellTime || getUser()->Poison::HasFlag(PoisonType::Stun))
        {
            getUser()->ClearMagic();
            return;
        }

        if ((CMain::Time <= magic->CastTime + magic->Delay) && magic->CastTime > 0)
        {
            if (CMain::Time >= OutputDelay)
            {
                OutputDelay = CMain::Time + 1000;
//C# TO C++ CONVERTER TODO TASK: There is no C++ equivalent to 'ToString':
                GameScene::Scene->OutputMessage(StringHelper::formatSimple("You cannot cast {0} for another {1} seconds.", magic->Spell.ToString(), ((magic->CastTime + magic->Delay) - CMain::Time - 1) / 1000 + 1));
            }

            getUser()->ClearMagic();
            return;
        }

        int cost = magic->Level * magic->LevelCost + magic->BaseCost;

        if (magic->Spell == Spell::Teleport || magic->Spell == Spell::Blink || magic->Spell == Spell::StormEscape)
        {
            if (GameScene::getUser()->Stats[Stat::TeleportManaPenaltyPercent] > 0)
            {
                cost += (cost * GameScene::getUser()->Stats[Stat::TeleportManaPenaltyPercent]) / 100;
            }
        }

        if (GameScene::getUser()->Stats[Stat::ManaPenaltyPercent] > 0)
        {
            cost += (cost * GameScene::getUser()->Stats[Stat::ManaPenaltyPercent]) / 100;
        }

        if (cost > MapObject::User->MP)
        {
            if (CMain::Time >= OutputDelay)
            {
                OutputDelay = CMain::Time + 1000;
                GameScene::Scene->OutputMessage(GameLanguage::LowMana);
            }
            getUser()->ClearMagic();
            return;
        }

        //bool isTargetSpell = true;

        MapObject *target = nullptr;

        //Targeting
        switch (magic->Spell)
        {
            case Spell::FireBall:
            case Spell::GreatFireBall:
            case Spell::ElectricShock:
            case Spell::Poisoning:
            case Spell::ThunderBolt:
            case Spell::FlameDisruptor:
            case Spell::SoulFireBall:
            case Spell::TurnUndead:
            case Spell::FrostCrunch:
            case Spell::Vampirism:
            case Spell::Revelation:
            case Spell::Entrapment:
            case Spell::Hallucination:
            case Spell::DarkBody:
            case Spell::FireBounce:
            case Spell::MeteorShower:
                if (getUser()->NextMagicObject != nullptr)
                {
                    if (!getUser()->NextMagicObject->Dead && getUser()->NextMagicObject->getRace() != ObjectType::Item && getUser()->NextMagicObject->getRace() != ObjectType::Merchant)
                    {
                        target = getUser()->NextMagicObject;
                    }
                }

                if (target == nullptr)
                {
                    target = MapObject::MagicObject;
                }

                if (target != nullptr && target->getRace() == ObjectType::Monster)
                {
                    MapObject::MagicObject = target;
                }
                break;
            case Spell::StraightShot:
            case Spell::DoubleShot:
            case Spell::ElementalShot:
            case Spell::DelayedExplosion:
            case Spell::BindingShot:
            case Spell::VampireShot:
            case Spell::PoisonShot:
            case Spell::CrippleShot:
            case Spell::NapalmShot:
            case Spell::SummonVampire:
            case Spell::SummonToad:
            case Spell::SummonSnakes:
                if (!getUser()->getHasClassWeapon())
                {
                    GameScene::Scene->OutputMessage("You must be wearing a bow to perform this skill.");
                    getUser()->ClearMagic();
                    return;
                }
                if (getUser()->NextMagicObject != nullptr)
                {
                    if (!getUser()->NextMagicObject->Dead && getUser()->NextMagicObject->getRace() != ObjectType::Item && getUser()->NextMagicObject->getRace() != ObjectType::Merchant)
                    {
                        target = getUser()->NextMagicObject;
                    }
                }

                if (target == nullptr)
                {
                    target = MapObject::MagicObject;
                }

                if (target != nullptr && target->getRace() == ObjectType::Monster)
                {
                    MapObject::MagicObject = target;
                }

                //if(magic.Spell == Spell.ElementalShot)
                //{
                //    isTargetSpell = User.HasElements;
                //}

                //switch(magic.Spell)
                //{
                //    case Spell.SummonVampire:
                //    case Spell.SummonToad:
                //    case Spell.SummonSnakes:
                //        isTargetSpell = false;
                //        break;
                //}

                break;
            case Spell::Purification:
            case Spell::Healing:
            case Spell::UltimateEnhancer:
            case Spell::EnergyShield:
            case Spell::PetEnhancer:
                if (getUser()->NextMagicObject != nullptr)
                {
                    if (!getUser()->NextMagicObject->Dead && getUser()->NextMagicObject->getRace() != ObjectType::Item && getUser()->NextMagicObject->getRace() != ObjectType::Merchant)
                    {
                        target = getUser()->NextMagicObject;
                    }
                }

                if (target == nullptr)
                {
                    target = getUser();
                }
                break;
            case Spell::FireBang:
            case Spell::MassHiding:
            case Spell::FireWall:
            case Spell::TrapHexagon:
                if (getUser()->NextMagicObject != nullptr)
                {
                    if (!getUser()->NextMagicObject->Dead && getUser()->NextMagicObject->getRace() != ObjectType::Item && getUser()->NextMagicObject->getRace() != ObjectType::Merchant)
                    {
                        target = getUser()->NextMagicObject;
                    }
                }
                break;
            case Spell::PoisonCloud:
                if (getUser()->NextMagicObject != nullptr)
                {
                    if (!getUser()->NextMagicObject->Dead && getUser()->NextMagicObject->getRace() != ObjectType::Item && getUser()->NextMagicObject->getRace() != ObjectType::Merchant)
                    {
                        target = getUser()->NextMagicObject;
                    }
                }
                break;
            case Spell::Blizzard:
            case Spell::MeteorStrike:
                if (getUser()->NextMagicObject != nullptr)
                {
                    if (!getUser()->NextMagicObject->Dead && getUser()->NextMagicObject->getRace() != ObjectType::Item && getUser()->NextMagicObject->getRace() != ObjectType::Merchant)
                    {
                        target = getUser()->NextMagicObject;
                    }
                }
                break;
            case Spell::Reincarnation:
                if (getUser()->NextMagicObject != nullptr)
                {
                    if (getUser()->NextMagicObject->Dead && getUser()->NextMagicObject->getRace() == ObjectType::Player)
                    {
                        target = getUser()->NextMagicObject;
                    }
                }
                break;
            case Spell::Trap:
                if (getUser()->NextMagicObject != nullptr)
                {
                    if (!getUser()->NextMagicObject->Dead && getUser()->NextMagicObject->getRace() != ObjectType::Item && getUser()->NextMagicObject->getRace() != ObjectType::Merchant)
                    {
                        target = getUser()->NextMagicObject;
                    }
                }
                break;
            case Spell::FlashDash:
                if (getUser()->GetMagic(Spell::FlashDash)->Level <= 1 && getUser()->IsDashAttack() == false)
                {
                    getUser()->ClearMagic();
                    return;
                }
                //isTargetSpell = false;
                break;
            default:
                //isTargetSpell = false;
                    break;
        }

        MirDirection dir = (target == nullptr || target == getUser()) ? getUser()->NextMagicDirection : Functions::DirectionFromPoint(getUser()->CurrentLocation, target->CurrentLocation);

        Point *location = target != nullptr ? target->CurrentLocation : getUser()->NextMagicLocation;

        if (magic->Spell == Spell::FlashDash)
        {
            dir = getUser()->Direction;
        }

        if ((magic->Range != 0) && (!Functions::InRange(getUser()->CurrentLocation, location, magic->Range)))
        {
            if (CMain::Time >= OutputDelay)
            {
                OutputDelay = CMain::Time + 1000;
                GameScene::Scene->OutputMessage("Target is too far.");
            }
            getUser()->ClearMagic();
            return;
        }

        GameScene::LogTime = CMain::Time + Globals::LogDelay;

        getUser()->QueuedAction = new QueuedAction();
        getUser()->QueuedAction->Action = MirAction::Spell;
        getUser()->QueuedAction->Direction = dir;
        getUser()->QueuedAction->Location = getUser()->CurrentLocation;
        getUser()->QueuedAction->Params = std::vector<std::any>();
        getUser()->QueuedAction->Params.push_back(magic->Spell);
        getUser()->QueuedAction->Params.push_back(target != nullptr ? target->ObjectID : 0);
        getUser()->QueuedAction->Params.push_back(location);
        getUser()->QueuedAction->Params.push_back(magic->Level);
    }

    MirDirection MapControl::MouseDirection(float ratio)
    {
        Point *p = new Point(MouseLocation->X / CellWidth, MouseLocation->Y / CellHeight);
        Point tempVar(OffSetX, OffSetY);
        if (Functions::InRange(&tempVar, p, 2))
        {
//C# TO C++ CONVERTER TODO TASK: A 'delete p' statement was not added since p was passed to a method or constructor. Handle memory management manually.
            Point tempVar2(OffSetX, OffSetY);
            return Functions::DirectionFromPoint(&tempVar2, p);
        }

        PointF *c = new PointF(OffSetX * CellWidth + CellWidth / 2.0F, OffSetY * CellHeight + CellHeight / 2.0F);
        PointF *a = new PointF(c->X, 0);
        PointF *b = MouseLocation;
        float bc = static_cast<float>(Distance(c, b));
        float ac = bc;
        b->Y -= c->Y;
        c->Y += bc;
        b->Y += bc;
        float ab = static_cast<float>(Distance(b, a));
        double x = (ac * ac + bc * bc - ab * ab) / (2 * ac * bc);
        double angle = std::acos(x);

        angle *= 180 / M_PI;

        if (MouseLocation->X < c->X)
        {
            angle = 360 - angle;
        }
        angle += ratio / 2;
        if (angle > 360)
        {
            angle -= 360;
        }

//C# TO C++ CONVERTER TODO TASK: A 'delete a' statement was not added since a was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete c' statement was not added since c was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete p' statement was not added since p was passed to a method or constructor. Handle memory management manually.
        return static_cast<MirDirection>(angle / ratio);
    }

    int MapControl::Direction16(Point *source, Point *destination)
    {
        PointF *c = new PointF(source->X, source->Y);
        PointF *a = new PointF(c->X, 0);
        PointF *b = new PointF(destination->X, destination->Y);
        float bc = static_cast<float>(Distance(c, b));
        float ac = bc;
        b->Y -= c->Y;
        c->Y += bc;
        b->Y += bc;
        float ab = static_cast<float>(Distance(b, a));
        double x = (ac * ac + bc * bc - ab * ab) / (2 * ac * bc);
        double angle = std::acos(x);

        angle *= 180 / M_PI;

        if (destination->X < c->X)
        {
            angle = 360 - angle;
        }
        angle += 11.25F;
        if (angle > 360)
        {
            angle -= 360;
        }

//C# TO C++ CONVERTER TODO TASK: A 'delete b' statement was not added since b was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete a' statement was not added since a was passed to a method or constructor. Handle memory management manually.
//C# TO C++ CONVERTER TODO TASK: A 'delete c' statement was not added since c was passed to a method or constructor. Handle memory management manually.
        return static_cast<int>(angle / 22.5F);
    }

    double MapControl::Distance(PointF *p1, PointF *p2)
    {
        double x = p2->X - p1->X;
        double y = p2->Y - p1->Y;
        return std::sqrt(x * x + y * y);
    }

    bool MapControl::EmptyCell(Point *p)
    {
        if ((M2CellInfo[p->X][p->Y].BackImage & 0x20000000) != 0 || (M2CellInfo[p->X][p->Y].FrontImage & 0x8000) != 0) // + (M2CellInfo[P.X, P.Y].FrontImage & 0x7FFF) != 0)
        {
            return false;
        }

        for (int i = 0; i < Objects.size(); i++)
        {
            MapObject *ob = Objects[i];

            if (ob->CurrentLocation == p && ob->getBlocking())
            {
                return false;
            }
        }

        return true;
    }

    bool MapControl::CanWalk(MirDirection dir)
    {
        return EmptyCell(Functions::PointMove(getUser()->CurrentLocation, dir, 1)) && !getUser()->InTrapRock;
    }

    bool MapControl::CheckDoorOpen(Point *p)
    {
        if (M2CellInfo[p->X][p->Y].DoorIndex == 0)
        {
            return true;
        }
        Door *DoorInfo = GetDoor(M2CellInfo[p->X][p->Y].DoorIndex);
        if (DoorInfo == nullptr)
        {
            return false; //if the door doesnt exist then it isnt even being shown on screen (and cant be open lol)
        }
        if ((DoorInfo->DoorState == (DoorState)0) || (DoorInfo->DoorState == DoorState::Closing))
        {
            C::Opendoor *tempVar = new C::Opendoor();
            tempVar->DoorIndex = DoorInfo->index;
            Network::Enqueue(tempVar);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
            return false;
        }
        if ((DoorInfo->DoorState == DoorState::Open) && (DoorInfo->LastTick + 4000 > CMain::Time))
        {
            C::Opendoor *tempVar2 = new C::Opendoor();
            tempVar2->DoorIndex = DoorInfo->index;
            Network::Enqueue(tempVar2);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar2' statement was not added since tempVar2 was passed to a method or constructor. Handle memory management manually.
        }
        return true;
    }

    bool MapControl::CanRun(MirDirection dir)
    {
        if (getUser()->InTrapRock)
        {
            return false;
        }
        if (getUser()->CurrentBagWeight > getUser()->Stats[Stat::BagWeight])
        {
            return false;
        }
        if (getUser()->CurrentWearWeight > getUser()->Stats[Stat::BagWeight])
        {
            return false;
        }
        if (CanWalk(dir) && EmptyCell(Functions::PointMove(getUser()->CurrentLocation, dir, 2)))
        {
            if (getUser()->RidingMount || getUser()->Sprint && !getUser()->Sneaking)
            {
                return EmptyCell(Functions::PointMove(getUser()->CurrentLocation, dir, 3));
            }

            return true;
        }

        return false;
    }

    bool MapControl::CanRideAttack()
    {
        if (GameScene::getUser()->RidingMount)
        {
            UserItem *item = GameScene::getUser()->Equipment[static_cast<int>(EquipmentSlot::Mount)];
            if (item == nullptr || item->Slots.size() < 4 || item->Slots[static_cast<int>(MountSlot::Bells)] == nullptr)
            {
                return false;
            }
        }

        return true;
    }

    bool MapControl::CanFish(MirDirection dir)
    {
        if (!GameScene::getUser()->getHasFishingRod() || GameScene::getUser()->FishingTime + 1000 > CMain::Time)
        {
            return false;
        }
        if (GameScene::getUser()->CurrentAction != MirAction::Standing)
        {
            return false;
        }
        if (GameScene::getUser()->Direction != dir)
        {
            return false;
        }
        if (GameScene::getUser()->TransformType >= 6 && GameScene::getUser()->TransformType <= 9)
        {
            return false;
        }

        Point *point = Functions::PointMove(getUser()->CurrentLocation, dir, 3);

        if (!M2CellInfo[point->X][point->Y].FishingCell)
        {
            return false;
        }

        return true;
    }

    bool MapControl::CanFly(Point *target)
    {
        Point *location = getUser()->CurrentLocation;
        while (location != target)
        {
            MirDirection dir = Functions::DirectionFromPoint(location, target);

            location = Functions::PointMove(location, dir, 1);

            if (location->X < 0 || location->Y < 0 || location->X >= GameScene::Scene->MapControl->Width || location->Y >= GameScene::Scene->MapControl->Height)
            {
                return false;
            }

            if (!GameScene::Scene->MapControl->ValidPoint(location))
            {
                return false;
            }
        }

        return true;
    }

    bool MapControl::ValidPoint(Point *p)
    {
        //GameScene.Scene.ChatDialog.ReceiveChat(string.Format("cell: {0}", (M2CellInfo[p.X, p.Y].BackImage & 0x20000000)), ChatType.Hint);
        return (M2CellInfo[p->X][p->Y].BackImage & 0x20000000) == 0;
    }

    bool MapControl::HasTarget(Point *p)
    {
        for (int i = 0; i < Objects.size(); i++)
        {
            MapObject *ob = Objects[i];

            if (ob->CurrentLocation == p && ob->getBlocking())
            {
                return true;
            }
        }
        return false;
    }

    bool MapControl::CanHalfMoon(Point *p, MirDirection d)
    {
        d = Functions::PreviousDir(d);
        for (int i = 0; i < 4; i++)
        {
            if (HasTarget(Functions::PointMove(p, d, 1)))
            {
                return true;
            }
            d = Functions::NextDir(d);
        }
        return false;
    }

    bool MapControl::CanCrossHalfMoon(Point *p)
    {
        MirDirection dir = MirDirection::Up;
        for (int i = 0; i < 8; i++)
        {
            if (HasTarget(Functions::PointMove(p, dir, 1)))
            {
                return true;
            }
            dir = Functions::NextDir(dir);
        }
        return false;
    }

    void MapControl::Dispose(bool disposing)
    {
        if (disposing)
        {
            Objects.clear();

            MapButtons = 0;
            MouseLocation = Point::Empty;
            InputDelay = 0;
            NextAction = 0;

            M2CellInfo = std::vector<std::vector<CellInfo*>>();
            Width = 0;
            Height = 0;

            FileName = "";
            Title = "";
            MiniMap = 0;
            BigMap = 0;
            Lights = (LightSetting)0;
            FloorValid = false;
            LightsValid = false;
            MapDarkLight = 0;
            Music = 0;

            AnimationCount = 0;
            Effects.clear();
        }

        MirControl::Dispose(disposing);
    }

    void MapControl::RemoveObject(MapObject *ob)
    {
        M2CellInfo[ob->MapLocation->X][ob->MapLocation->Y].RemoveObject(ob);
    }

    void MapControl::AddObject(MapObject *ob)
    {
        M2CellInfo[ob->MapLocation->X][ob->MapLocation->Y].AddObject(ob);
    }

    MapObject *MapControl::FindObject(unsigned int ObjectID, int x, int y)
    {
        return M2CellInfo[x][y].FindObject(ObjectID);
    }

    void MapControl::SortObject(MapObject *ob)
    {
        std::sort(M2CellInfo[ob->MapLocation->X][ob->MapLocation->Y].begin(), M2CellInfo[ob->MapLocation->X][ob->MapLocation->Y].end());
    }

    Door *MapControl::GetDoor(unsigned char Index)
    {
        for (int i = 0; i < Doors.size(); i++)
        {
            if (Doors[i]->index == Index)
            {
                return Doors[i];
            }
        }
        return nullptr;
    }

    void MapControl::Processdoors()
    {
        for (int i = 0; i < Doors.size(); i++)
        {
            if ((Doors[i]->DoorState == DoorState::Opening) || (Doors[i]->DoorState == DoorState::Closing))
            {
                if (Doors[i]->LastTick + 50 < CMain::Time)
                {
                    Doors[i]->LastTick = CMain::Time;
                    Doors[i]->ImageIndex++;

                    if (Doors[i]->ImageIndex == 1) //change the 1 if you want to animate doors opening/closing
                    {
                        Doors[i]->ImageIndex = 0;
//C# TO C++ CONVERTER TODO TASK: There is no C++ equivalent to the C# 'typeof' operator:
                        Doors[i]->DoorState = static_cast<DoorState>(Enum::ToObject(typeof(DoorState), ((unsigned char)++Doors[i]->DoorState % 4)));
                    }

                    FloorValid = false;
                }
            }
            if (Doors[i]->DoorState == DoorState::Open)
            {
                if (Doors[i]->LastTick + 5000 < CMain::Time)
                {
                    Doors[i]->LastTick = CMain::Time;
                    Doors[i]->DoorState = DoorState::Closing;
                    FloorValid = false;
                }
            }
        }
    }

    void MapControl::OpenDoor(unsigned char Index, bool closed)
    {
        Door *Info = GetDoor(Index);
        if (Info == nullptr)
        {
            return;
        }
        Info->DoorState = (closed ? DoorState::Closing : Info->DoorState == DoorState::Open ? DoorState::Open : DoorState::Opening);
        Info->ImageIndex = 0;
        Info->LastTick = CMain::Time;
    }
}
